Python import inconsistent behavior -


i have py file this, errors out.

from world import acme  def make_stuff_happen():     acme.account.foo()       # works     acme.subscription.bar()  # fail: "module 'object' has no attribute 'subscription'"  make_stuff_happen() 

but works!

from world import acme  world.acme import subscription  def make_stuff_happen():     acme.account.foo()  # works     subscription.bar()  # works.  make_stuff_happen() 

all can wtf, causing this? behavior should @ least consistent both acme.account , acme.subscription.

thanks!

update- folder structure of acme folder:

acme |-- __init__.py |-- account.py |-- catalog.py |-- core.py |-- proxy.py |-- subscription.py `-- utils.py 

and __init__.py blank.

submodules referenced in __init__.py file in module folder. appears subscription not referenced in acme's __init__.py.

however, when import world.acme.subscription, knows go digging in folder without talking __init__.py.

according description of __init__.py being empty, should import subscription in __init__.py.

more on how modules set can seen in documentation. there pretty example setting sound module.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -