[Tutor] Help with packages and namespaces please

Kent Johnson kent37 at tds.net
Wed Oct 17 22:57:00 CEST 2007


Andrew Wu wrote:
> Thanks again for your help.
> 
> I guess I should ask a more basic question about hierarchical directory 
> structures and packages.  If I have a bunch of files in a flat (single) 
> directory structure that I want to reorganize into a hierarchical 
> directory structure, do I necessarily have to turn them into package 
> files ( i.e. add the __init__.py files, or can I simply place them into 
> a subdirectory structure and do something else so python can find the 
> modules?

You can put the subdirectories on the Python search path.

> Or is it better practice whenever a hierarchical directory structure 
> exists to treat it as a package? 

That is more common.

Kent


More information about the Tutor mailing list