Importing module from another subdirectory

Rich Shepard rshepard at appl-ecosys.com
Wed Apr 24 11:40:19 EDT 2019


On Wed, 24 Apr 2019, dieter wrote:

> "sys.path" tweaks are typically employed with a "central" Python
> installation, to have it look at non-standard places for module/packages
> under specific circumstances.

Almost all python packages installed here are built using the
SlackBuilds.org scripts (I run Slackware, currently -14.2) and I'd rather
keep current using the SBo scripts rather than importing via PyPi.

Most web search results I've found for appending to sys.path (or using the
site package) refer to python2, not the installed version 3.7.x.

The current project's directory structue is:

bustrac/
     README.rst
     bustrac.py*
     controller/
     model/
     scripts/
     views/

If I correctly understand the process, in bustrac.py I'll add
import sys.path
sys.path.append(controller, model, scripts, views)

Which would place the project-specific directories in the search path.

While developing the application and testing each view module I would place
the same import and sys.path.append() commands in the module being developed
and tested. Is this correct?

Thanks again,

Rich





More information about the Python-list mailing list