J
Joel Hedlund
Hi!
I have a possibly dumb question about imports. I've written two python
modules:
parser.py
------------------------------------
class Parser(object):
"my parser"
------------------------------------
app.py
------------------------------------
from parser import Parser
print "import successful"
------------------------------------
Running app.py on linux, gives:
------------------------------------
import succesful
------------------------------------
However, runnning it on windows gives:
------------------------------------
Traceback (most recent call last):
File "test.py", line 1, in ?
from parser import Parser
ImportError: cannot import name Parser
------------------------------------
It turns out that on Windows, the builtin parser module is imported
instead. Why? Why is there a difference? What other names are "taken"?
In both cases the script dir is first on sys.path, and I'm using the
plain old terminal/cmd window.
Thanks for your time.
Cheers!
/Joel Hedlund
I have a possibly dumb question about imports. I've written two python
modules:
parser.py
------------------------------------
class Parser(object):
"my parser"
------------------------------------
app.py
------------------------------------
from parser import Parser
print "import successful"
------------------------------------
Running app.py on linux, gives:
------------------------------------
import succesful
------------------------------------
However, runnning it on windows gives:
------------------------------------
Traceback (most recent call last):
File "test.py", line 1, in ?
from parser import Parser
ImportError: cannot import name Parser
------------------------------------
It turns out that on Windows, the builtin parser module is imported
instead. Why? Why is there a difference? What other names are "taken"?
In both cases the script dir is first on sys.path, and I'm using the
plain old terminal/cmd window.
Thanks for your time.
Cheers!
/Joel Hedlund