[Tutor] can't import module

Dave S pythontut at pusspaws.net
Sun Jul 2 21:16:49 CEST 2006


On Sunday 02 July 2006 20:12, Alan Gauld wrote:
> > As far a putting everything into a package - I am a bit lost. Do you
> > mean one
> > big .py script or am I misunderstanding you ?
>
> You misunderstand him.
>
> Python allows you to  reate a package structure of directories and
> files
> such that all of the files within the top level directory and the
> subdirectories
> are searched so you only need to specify the top level directory for
> all the
> files in subndirectories to be found.
>
> This requires creating some magic python definition files.
> Check the docs for details.
>
> The end result is that in pythonpath you add
>
> /some/path/myPackage
>
> and in your code you do
>
> from myPackage import someModule
>
> Check the docs for details.
>
> Alan G.

Thanks for that - I never realised you could do that. It sound like a good 
solution and a lot less messy than the way I have created my own modules & 
scripts.

Dave


More information about the Tutor mailing list