open(False) in python3

geremy condra debatem1 at gmail.com
Wed May 12 12:53:18 EDT 2010


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.

Thanks for the advice, everybody.

Geremy Condra



More information about the Python-list mailing list