A tale of two execs

aha aquil.abdullah at gmail.com
Mon Feb 23 11:53:20 EST 2009


Hello All,
  I am working on a project where I need to support versions of Python
as old as 2.3. Previously, we distributed Python with our product, but
this seemed a bit silly so we are no longer doing this.  The problem
that I am faced with is that we have Python scripts that use the
subprocess module, and subprocess is not available in Python 2.3.
Below is the strategy I am thinking about using, however if, you have
better ideas please let me know.

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?



More information about the Python-list mailing list