2

Trying to understand how to properly use another module when its nested within a folder. I tried implementing a package using the __init__.py as documented in the Packages section of Modules. I am not finding much success. Here is the file structure.

File Structure

For example, I want to be able to reference a class contained within credentials.py in propeller.py. Another use case, I want to reference a function from within base.py in propeller.py. Looking forward to hearing how other approach this. Thanks!

  • Fundamentally, you need to be able to find the file you are looking for from the PATH variable. Usually, "installing" a module involves adding the root directory of your library to the PATH. In a *nix system, something like: https://askubuntu.com/questions/250929/pythonpath-environment-variable – juanpa.arrivillaga Nov 15 '17 at 01:11

1 Answers1

0

It depends. Is the main module 'the_machine' in your Module Search Path? If so, you should be able to import the_machine.credentials. Otherwise, either add it to your sys.path or import it directly using the path..

RobertB
  • 1,879
  • 10
  • 17