open(False) in python3

Stefan Behnel stefan_ml at behnel.de
Wed May 12 04:36:27 EDT 2010


Johan Förberg, 12.05.2010 10:05:
> On Tue, 11 May 2010 19:27:37 -0300, Gabriel Genellina wrote:
>
>> so open(False) is the same as open(0), and 0 is the file descriptor
>> associated to standard input. The program isn't hung, it's just waiting
>> for you to type some text
>
> 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.

Standard Unix behaviour dictates that 0 is stdin, 1 is stdout, and 2 is 
stderr. So you can only read() from 0.

Stefan




More information about the Python-list mailing list