2

Why does this work?

with open(False) as f: s = f.read() 

I know this is an unimportant question but answers I've heard so far about OI open and waiting for an EOF token just doesn't seem to make sense as I've gotten this to work for True 1 and 0

1
  • 1
    False has an integer value of 0. My guess is that open is treating it as a file descriptor. Commented Jan 16, 2020 at 18:57

1 Answer 1

3

open can take an integer representing an existing file descriptor, and False (aka 0) is the file descriptor for standard input.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.