Organizing Code - Packages

GuillaumeC fructidor00 at gmail.com
Sun Sep 9 09:28:57 EDT 2007


On Sep 9, 1:04 am, xkenneth <xkenn... at gmail.com> wrote:
> On Sep 8, 3:35 pm, David <wizza... at gmail.com> wrote:
>
> > > How do import statements that are declared at the top of a python
> > > module work?
>
> >http://docs.python.org/tut/node8.html
> On Sat, 08 Sep 2007 12:42:19 -0700, xkenneth wrote:
> > How do import statements that are declared at the top of a python
> > module work?
>
> They import the module.  ;-)

Well, not only... They also include the names in the namespace. Using
the "import * from" form will bind in each of your modules the name of
the errors. You should use import XXX and then use the qualified name
XXX.myfunction. Then, you avoid conflicts between names and binding
every name from your module. See the documentation for reload() also.

>   Also, are there any good tutorials/examples out there of how to
> organize your python code into packges?

This is not new, nor specific to Python, but I think it is a good
reference:
http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
see section: Principles of Package Architecture





More information about the Python-list mailing list