Using __init__ to connect modules

Keyboard Shortcuts

As your project becomes larger and larger, you naturally break it out into several Python modules. It is complicated to find modules that are located in different subfolders. One practical way to get around this limitation is to use the init.py module.

- [Instructor] Previously,…we saw how to avoid spaghetti code.…We can use the init.py module…to connect different Python modules…by entering code into it.…This video will show how to do this.…When we create a new Python project…using the PyDev plugin for the Eclipse IDE,…it automatically creates an init.py module.…We can create it ourselves manually…when not using Eclipse.…The init.py module is usually empty…and has a size of zero kilobytes.…

We will use this empty module…to connect our different modules.…We will create a new GUI,…similar to the one we created in the previous video.…How to do it:…As a project becomes larger and larger,…we naturally break it out into several Python modules.…Using a modern IDE, such as Eclipse,…it is surprisingly 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.…As we haven't run any program as of yet,…the file has not been created automatically.…

Resume Transcript Auto-Scroll

Author

Released

7/7/2017

Learn how to create effective graphical user interfaces (GUIs) with minimal code using Python. Burkhard Meier starts by showing how to create a GUI form, add widgets, manage the resulting layout, and customize the look and feel of the interface. Then, he takes you through working with data, classes, and making charts using the 2D Python plotting library, Matplotbil. Next, he discusses how threading and networking impact the performance of your code. Later in the course, he advances on to working with databases, testing application GUIs, extending a GUI using the wxPython library, and creating 3D GUIs by using PyOpenGL and Pyglet. As you follow along with Burkhard throughout this course, you will develop an entire application's GUI.

Note: This course was created by Packt Publishing. We are pleased to host this training in our library.