os.popen varies return type depending on exit status?

David M. Wilson dw-google.com at botanicus.net
Fri Mar 5 06:30:10 EST 2004


Hi there, on Linux:

   >>> [ type(popen(cmd).close()) for cmd in ( 'true', 'foo' ) ]
   sh: line 1: foo: command not found
   [<type 'NoneType'>, <type 'int'>]


This feels inconsistent to me, and it just bit me because I was
expecting a 0 exit status on success, not None. Does close() return
this for historic reasons?


David.



More information about the Python-list mailing list