[Python-Dev] PEP 389: argparse - new command line parsing module

Antoine Pitrou solipsis at pitrou.net
Thu Oct 8 00:24:08 CEST 2009


Hrvoje Niksic <hrvoje.niksic <at> avl.com> writes:
>> 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:

Python 3 complains at startup and is a bit more explicit:
$ ./python -c '1' >&-
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor
Abandon
Of course, if it is stderr that you explicitly close, you lose all reporting:
$ ./python -c '1' 2>&-
Abandon
Regards
Antoine.


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /