[Tutor] Import from project's lib directory?
Danny Yoo
dyoo at hashcollision.org
Thu Aug 28 20:19:44 CEST 2014
On Thu, Aug 28, 2014 at 11:03 AM, leam hall <leamhall at gmail.com> wrote:
> python 2.4.3 on Red Hat Linux.
>
> I'm starting a project and want to break the scripts into "input",
> "output", and "ddl". I'd like to have a "lib" library directory for
> local modules. The library directory would be at the same level as the
> others.
>
> How do I get the library modules?
>
> import '../lib/mymodule'
You're looking for relative imports:
https://docs.python.org/2.5/whatsnew/pep-328.html
So for your case, perhaps:
from ..lib import mymodule
Alternatively, perhaps refer to the modules by toplevel package
instead of relative path?
More information about the Tutor
mailing list