
April 10, 2012
6:30 a.m.
On Tue, Apr 10, 2012 at 12:55 PM, Oleg Broytman <phd@phdru.name> wrote:
Why does a submodule import the entire package instead of importing just root?
import tree, sys print("tree.branch: 'root' in dir(tree) ->", 'root' in dir(tree)) print("tree.branch: 'tree.root' in sys.modules ->", 'tree.root' in sys.modules) Ignore this part - my fault. It should have been: import sys print("tree.branch: 'root' in dir(main) ->", 'root' in dir(sys.modules['__main__'])) print("tree.branch: 'tree.root' in sys.modules ->", 'tree.root' in sys.modules) This shows that `root` attribute does not exist yet in main, though 'tree.root' exists in `sys.modules`. -- *Victor*
4726
Age (days ago)
4726
Last active (days ago)
0 comments
1 participants
participants (1)
-
Victor Varvariuc