Write better structured modules and packages

Python import statement
Python import statement

If you’ve been working with Python for a while, you’ve probably come across the “__main__ idiom”. It consists of a couple of lines of code that usually look like this:

In this article, I would like to explore the meaning of these lines in some greater depth and use this common pattern as a starting point for an exploration of Python’s import machinery. This should help you understand better what is happening during import, and also help you to bring structure into your own modules and packages. …

Paul Papacz

Software Developer | Data Engineer | Former Scientist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store