On 21Dec2014 01:31, Terry Reedy <tjre...@udel.edu> wrote:
On 12/21/2014 12:31 AM, Chris Angelico wrote:
On Sun, Dec 21, 2014 at 4:14 PM, CM <cmpyt...@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.

He means file descriptor 1. sys.stdout does not have a file descriptor at all under IDLE.

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.

Please cite that doc. OSX _is_ UNIX, like almost all modern platforms.
A glance at a set of 3.4.0 docs convenient to hand finds only one call explicitly labelled as not working under MacOS (os.fdatasync).

Python io streams are not required to have a file descriptor.

Indeed, but the program cited relies on one. So it is not perfectly portable, but still widely usable.

Cheers,
Cameron Simpson <c...@zip.com.au>

Tachyon: A gluon that's not completely dry.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to