Python - werid behavior
Posted
by orokusaki
on Stack Overflow
See other posts from Stack Overflow
or by orokusaki
Published on 2010-04-15T16:20:40Z
Indexed on
2010/04/15
16:23 UTC
Read the original article
Hit count: 275
python
I've done what I shouldn't have done and written 4 modules (6 hours or so) without running any tests along the way.
I have a method inside of /mydir/__init__.py
called get_hash()
, and a class inside of /mydir/utils.py
called SpamClass
.
/mydir/utils.py
imports get_hash()
from /mydir/__init__
.
/mydir/__init__.py
imports SpamClass
from /mydir/utils.py
.
Both the class and the method work fine on their own but for some reason if I try to import /mydir/
, I get an import error saying "Cannot import name get_hash"
from /mydir/__init__.py
.
The only stack trace is the line saying that __init__.py
imported SpamClass
. The next line is where the error occurs in in SpamClass
when trying to import get_hash
. Why is this?
© Stack Overflow or respective owner