Hello World

Terry Reedy tjreedy at udel.edu
Sun Dec 21 01:31:14 EST 2014


On 12/21/2014 12:31 AM, Chris Angelico wrote:
> On Sun, Dec 21, 2014 at 4:14 PM, CM <cmpython at gmail.com> wrote:
>> I ran it in IDLE with Python 2.7.8 and got:
>>
>> Traceback (most recent call last):
>>    File "C:/Python27/helloworld.py", line 39, in <module>
>>      lambda _, __, ___, ____, _____, ______, _______, ________: _
>>    File "C:/Python27/helloworld.py", line 21, in <lambda>
>>      _))) + (_____ << ______) + (_ << ___)
>> OSError: [Errno 9] Bad file descriptor
>
> Yes, because - like most "Hello world" programs - it attempts to write
> to stdout. This interferes with IDLE and the way it captures output
> for the graphical environment.

Just to be clear, writing to sys.stdout works fine in Idle.
 >>> import sys; sys.stdout.write('hello ')
hello  #2.7

In 3.4, the number of chars? bytes? is returned and written also.

Whether you mean something different by 'stdout' or not, I am not sure. 
  The error is from writing to a non-existent file descriptor.
The os 'file descriptor functions are unix functions.  Many but not all 
also work on Windows.  I do not believe that was true on msdos. 
According to the os doc, they do not work on osx.  Python io streams are 
not required to have a file descriptor.

-- 
Terry Jan Reedy




More information about the Python-list mailing list