how to import subprocess into my 'subprocess.py' file

hiral hiralsmaillist at gmail.com
Wed May 5 06:34:06 EDT 2010


Hi,

I am doing following in my 'subprocess.py' file...

  1 from __future__ import absolute_import
  2 from subprocess import *
  3 from subprocess import call as myCall
  4 from subprocess import Popen as myPopen
  5
  6 def getProperCmd(cmd):
  7     cmd += 'time' # this is just an example; in fact I am doing
lots of processing on cmd
  8     return cmd
  9
 10
 11 def call(cmd, **kwargs):
 12     return myCall(getProperCmd(cmd), **kwargs)
 13
 14 def Popen(cmd, **kwargs):
 15     return myPopen(getProperCmd(cmd), **kwargs)

When running this it gives following error...
<error>
Traceback (most recent call last):
  File "subprocess.py", line 2, in <module>
    from subprocess import *
  File "subprocess.py", line 3, in <module>
    from subprocess import call as myCall
ImportError: cannot import name call
</error>

So how can I create a python file (with the same name as standard
module name) with custom methods?

Thank you in advance.
-Hiral



More information about the Python-list mailing list