Import Your Python Package as a Module
A python module is a single python file (.๐ฝ๐). An organized collection of such python files is called a python package.
While developing large projects, it is a good practice to define an __๐ถ๐ป๐ถ๐__.๐ฝ๐ file inside a package.
Consider ๐๐ฟ๐ฎ๐ถ๐ป.๐ฝ๐ has a ๐ง๐ฟ๐ฎ๐ถ๐ป๐ถ๐ป๐ด class and ๐๐ฒ๐๐.๐ฝ๐ has a ๐ง๐ฒ๐๐๐ถ๐ป๐ด class.
Without __๐ถ๐ป๐ถ๐__.๐ฝ๐, one has to explicitly import them from specific python files. As a result, it is redundant to write the two import statements.
With __๐ถ๐ป๐ถ๐__.๐ฝ๐, you can group python files into a single importable module. In other words, it provides a mechanism to treat the whole package as a python module.
This saves you from writing redundant import statements and makes your code cleaner in the calling script.
Read more in this blog:ย Blog Link.
Read this post on LinkedIn: Post Link.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.