[Tutor] Help with packages and namespaces please

Andrew Wu andrewwu at gmail.com
Tue Oct 16 01:52:16 CEST 2007


After a more careful perusing and sifting of your response, I discovered
this helped my understanding a lot better:


>
> You can bring names into the package namespace, but the actual code will
> still run in the module where it is defined. For example, in
> PrintMe/PrintBase/__init__.py you can say
>    from PrintBase import Printbase
>
> Hmm. I'm not sure if this will work the way you want because of the name
> collisions. Using the sound example where the names are unique, suppose
> wavread.py includes a function read_wav(). Then in Formats/__init__.py
> you can say
>    from wavread import read_wav
>
> This imports the name read_wav into the Formats package namespace so
> other code will be able to say
>    from Sound.Formats import read_wav



This above seems to be closest to what I'm hoping to achieve ... I will try
this out and see how it goes.  Thanks again!


Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071015/51229270/attachment.htm 


More information about the Tutor mailing list