How to do it...

As our project becomes larger and larger, we naturally break it out into several Python modules. Sometimes it can be a little bit complicated to find modules that are located in different subfolders, either above or below the code that needs to import it.

One practical way to get around this limitation is to use the __init__.py module.

In Eclipse, we can set the Eclipse internal project PyDev PYTHONPATH to certain folders and our Python code will find it. But outside Eclipse, for example, when running from a command window, there is sometimes a mismatch in the Python module import mechanism, and the code will not run.

Here is a screenshot of the empty __init__.py module which appears not with the name __init__ but with the ...

Get Python GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.