access to submodules

TG girodt at gmail.com
Wed Jul 19 10:21:03 EDT 2006


BartlebyScrivener wrote:
> then you no longer need tom, you imported all of his FUNCTIONS (never
> heard of submodule).

my mistake, I was using the wrong name

tom/ <-- package
   __init__.py
   core.py      <
   data.py     < these are modules contained in tom/
   ui.py          <


if I import tom, it is supposed to load functions defined in
tom/__init__.py and make all the modules inside accessible through the
"dot" syntax.

Therefore, this is supposed to work :

?> import tom
?> help(tom.core)

AttributeError: 'module' object has no attribute 'core'

But if I use the baaaaad star syntax

?> from tom import *
?> help(core)

this will work. So that means star loaded functions of __init__.py AND
modules contained, whereas dot syntax does not give me access to
modules inside. The issue is not about using or not using the import *
...




More information about the Python-list mailing list