popen exit status

Pedro Rodriguez pedro_rodriguez at club-internet.fr
Mon Jan 28 13:45:19 EST 2002

"david" <me at here.com> wrote:

> the documentation says that popen returns the error code, or 'None', of
> the shell process. this code however always returns '1' even though the
> command operates fine.
>         f=os.popen("ls /dev/loop*")
>         loopdevices = f.read()
>         if not f.close() == 'None':         #fails on <>0: also
>             raise Exception, "couldn't find any loop devices."

Remove the quotes around None. Like in :

          if f.close() is not None:



More information about the Python-list mailing list