Importing module from another subdirectory

Rich Shepard rshepard at appl-ecosys.com
Mon Apr 22 14:02:24 EDT 2019


On Thu, 18 Apr 2019, dieter wrote:

> I see two options for you:
>
> 1. put your scripts directly into "bustrac" (rather than a subdirectory)

There are too many files; the directory is very cluttered.

> 2. extend "sys.path" in your scripts to contain the "bustrac" folder
> (before you try to import infrastructure modules/packages)

I read the docs for sys and site and have insufficient experience with them
to know how best to apply them for my needs.

My research suggests that rather than appending a project directory tree to
sys.path (which would make it visible to all python invocations) I'd be
better off using site within each project's root directory so modules in
project-specific subdirectories are available to that project. I would like
advice on how to do this.

Or, can I extend sys.path within each project's root directory so the
extension applies only there?

Regards,

Rich




More information about the Python-list mailing list