How it works...

In this recipe, we imported a function from a module that is nested in a folder structure.

We saw that we can use the __init__.py module to add the folder structure to the Python search path. We did this by first adding code to, and then explicitly importing, the __init__.py module.

In a loop, we search the directory structure until we find the root folder we are looking for.

We then get the full path to this folder and append the three folders. We are not hardcoding the entire search path. We only append the known folders to wherever our module is located.

Using the code we added to the __init__.py module enabled us to run the code successfully both from within Eclipse as well as from a command prompt.

Using pure Python is usually the best way to go.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.227.82