Paul Moore wrote: > Traceback (most recent call last): > File "hello.py", line 13, in <module> > main() > File "hello.py", line 7, in main > sys.stdout.flush() > IOError: [Errno 9] Bad file descriptor > > (Question - is it *ever* possible for a Unix program to have invalid > file descriptors 0,1 and 2? At startup - I'm assuming anyone who does > os.close(1) knows what they are doing!) Of course; simply use the >&- pseudo-redirection, which has been a standard sh feature (later inherited by ksh and bash, but not csh) for ~30 years. The error message is amusing, too: $ python -c 'print "foo"' >&- close failed in file object destructor: Error in sys.excepthook: Original exception was: Adding an explicit flush results in a more understandable error message: Traceback (most recent call last): File "<string>", line 1, in <module> IOError: [Errno 9] Bad file descriptor
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4