[Tutor] Import package module problem
mandel at themacaque.com
mandel at themacaque.com
Mon May 11 22:44:09 CEST 2009
Hello there,
I have just started working with python and I have some issues
understanding how I should be importing modules from packages. Curretly I
have the following tree structure:
general/
__init__.py
address_book.py
groups/
__init__.py
contact_group.py
where groups and general are in the same level and all the __init__.py
files are empty.
In address_book.py I want to import the ContactGroup which is at
contact_group.py. I have try the following posibilities:
from ..groups.contact_group import ContactGroup
from groups.contact_group import ContactGroups
from groups.contact_group import *
But I cannot get it working. I know that the third option will not work
because I have not set up __all__ but I do not understand why it does not
work. I have read books and tutorials about it, but I cannot get it.
Am I doing something wrong? I would really appreciate a hand or pointer to
s step by step example.
Kr,
Manuel
More information about the Tutor
mailing list