open(False) in python3

Christian Heimes lists at cheimes.de
Wed May 12 04:42:41 EDT 2010


Johan Förberg every:
> That's interesting. Are there any more numbered pseudofiles? I suppose
> its mainly an excellent way to confuse people when you open(0).read(),
> but it would be interesting to know.

All opened files (and on Unix even network sockets, epoll queues, 
inotify handlers etc) have a number. It's called a file descriptor. By 
default stdin, stdout and stderr have the file descriptors 0, 1 and 2. 
The concept of file descriptors is much older than Python and not Python 
specific. Even shells use the numbers, e.g. "cmd >logfile 2>&1" means 
"write stdout to logfile, redirect and combine stderr stream with stdout".




More information about the Python-list mailing list