open(False) in python3

Martin v. Loewis martin at v.loewis.de
Wed May 12 16:24:09 EDT 2010


geremy condra wrote:
> On Wed, May 12, 2010 at 1:36 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> 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
> 
> Nitpicking, but open(1).read() and open(2).read() both succeed
> (for small values of success) the same way that open(0).read()
> does.

That's because your operating system made that so. Try a different
operating system, and you may get different results.

Regards,
Martin



More information about the Python-list mailing list