Message285653
Builtin open() in Python 3 (and io.open() in Python 2.7) accept unicode strings, byte strings and integers as the first arguments (general path-like objects also are supported in Python 3.6, but it doesn't matter). bool is a subtype of int, and False is equal to integer 0. 0 is a file descriptor of sys.stdin.
>>> import sys
>>> sys.stdin.fileno()
0
Thus open(False) is equivalent to open(sys.stdin.fileno()). It creates a file object that wraps the file descriptor 0. This is legitimate operation. |
|
Date |
User |
Action |
Args |
2017-01-17 15:20:15 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, Mo Ali |
2017-01-17 15:20:15 | serhiy.storchaka | set | messageid: <1484666415.53.0.758229659838.issue29297@psf.upfronthosting.co.za> |
2017-01-17 15:20:15 | serhiy.storchaka | link | issue29297 messages |
2017-01-17 15:20:15 | serhiy.storchaka | create | |
|