hiral wrote:
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
Just don't do that, find another name.
Dont use * in import statement:
"Namespaces are one honking great idea -- let's do more of those!"
("import this" in a shell for more rules)
Using * in import statements removes namespaces.
JM
--
http://mail.python.org/mailman/listinfo/python-list