This was strange, I had a bunch of classes in a file and was trying to import one of them from a file in a child folder.
The package looked like this:
/main_classes.py <– “import child” was in here way on top
/child/__init__.py <– For every file in this folder, import it
/child/some_file.py <– Import a class in main_classes.py *Error*
The reason was that I was doing “import child” way on top before implementing the class I was importing in some_file.py.
I moved the “import child” line from the top of the main_class.py to the constructor of the class I was implementing and it fixed the issue.
I hope this made sense
(and I know it will to the person with this problem
)
Hamid Alipour is a partner in Codehead, LLP with his wife, Tess. Hamid speaks 12 markup and programming languages [Yes, 12: PHP, CSS, Ajax, JavaScript, HTML/XHTML, Java, Python, C/C++, ASP, Visual Basic, Scheme and Action Script]; has a penchant for solving the unsolvable; an affinity for clean, hand-written code and is a Zend Certified 
Thanks a lot! That was a very useful post
And yes, it made sense
Comment
yes, kewl post, mr. snake-charmer — solved my problem too
now i can continue choking the snake.
Comment
and what happen if you hace a bouch of classes on:
/ab/ab_classes.py
and now make a package like this:
/a/a_classes.py
/b/b_classes.py
???
Comment
ok ok ok I got, niceeeee. thanks.
Comment
Thx for the info – it also solved my problem – but i had to reread your post quite often to understand it.
The problem is a **circular Reference** – as child gets imported in parent, which also wants to import parts of parent.
Comment
thanks a lot for the post. it does make sense to me.
Comment
Thanks a lot, saved me a lot of searching
Comment
thanks so much for solving my problem.
***would take “years” to find it.heheheeh…
saved me a lot of searching [2]!
Comment