aha wrote
> def runner(cmd, stdin, stdout, ...):
>   try:
>     import subprocess
>     sbm = 1
>   except:
>     sbm = 0
> 
>   # Now do something
>   if sbm:
>     process = subporcess(...)
>   else:
>     import popen2
>     process = popen2.Popen4(...)
> 
> Has anyone else run into a situation similar to this one?

The canonical way for your try/except clause is:

try:
    import subprocess
except ImportError:
    subprocess = None

...

if subprocess is not None:
    ...
else:
    ...

Christian

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to