Cribbed from a tweet by Raymond Hettinger: quiz – what does this do?

with open(False) as f:
s =

@rixx without peeking in the source, I'd guess reading a line from stdin?

@rixx Thats interesting.
open(False) reads stdin. So:


Will wait endless on keyboard inputs.

>>> X = open(False).read(10)
Hallo Welt
>>> X
'Hallo Welt'

This store only the 10 first characters from keyboard input in X.

Thanks !

@rixx Produces an error because the indentation is missing?

@quantum That seems to be a client issue on your part, because the status does have indentation:

@rixx Oh. Good to know about that!
Then it reads a line from stdin.

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!