[Tutor] Import from project's lib directory?

leam hall leamhall at gmail.com
Fri Aug 29 16:25:24 CEST 2014


On Fri, Aug 29, 2014 at 9:39 AM, diliup gabadamudalige
<diliupg at gmail.com> wrote:
> this is the easiest way to do this
>
> # one.py is in the \data\ directory
> # two.py is in the \data\img\ directory
> # three.py is in the \data\img\sc\ directory
>
> ## this program is in the learn_music dir
>
> ## expanding the file path add a . before the new dir
>
> ## each directory you need to load a module from needs to have __init__.py
> file inside the directory. It can be an empty file but it needs to be there.
> That's how python knows that you can load a module from this directory. my
> one.py, two.py and three.py modules each have a string called a in it. You
> can have classes or functions which can be called in the same way.
>
> from data import one  # / data/
> from data .img import two  # /data/img/
> from data .img.sc import three  # /data/img/sc/
>
> print one.a, two.a, three.a
>
> hope this helps


So far this doesn't work. I'm pretty convinced it's either a Python
version issue (2.4.3 and 2.6.6.) or pure Operator Error. Leaning
towards the latter.

Thanks!

Leam
-- 
Mind on a Mission


More information about the Tutor mailing list