On Wed, 7 Jun 2000, Andy Robinson wrote: > We hit some very weird behaviour recently while setting up a package > hierarchy. Robin Becker managed to distil this into a simple example. > Can anyone shed any light on what is happening below? Is Python > behaving as it should? It looks to me like you have two "parent" modules. When you run "test.py" directly from the command line, the first "from parent import *" imports parent.py as module "parent". But subsequently parent.py is imported again as module "A.parent". Similarly, you have two "Examiner" classes. In run0() you get Examiner from __main__, which contains the Parent class from module "parent". In run1() you get Examiner from A.test, which contains the Parent class imported from module "A.parent". If you insert print 'in module', __name__, 'parent is', repr(Parent) at the beginning of the examine() method, it should make things clear. The solution is to avoid directly running scripts that are inside packages; the confusion is produced by the fact that you're running "test.py" from within the A/ directory. -- ?!ng
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4