Computer Science
What is the use of file __init__.py in a package even when it is empty ?
Python Libraries
4 Likes
Answer
The use of file __init__.py in a package even when it is empty is that without the __init__.py file, Python will not look for submodules inside that directory, so attempts to import the module will fail. Hence, the file __init__.py in a folder, indicates it is an importable Python package.
Answered By
3 Likes
Related Questions
What is a package ? How is a package different from module ?
What is a library ? Write procedure to create own library in Python.
What is the importance of site-packages folder of Python installation ?
How are following import statements different ?
(a) import X
(b) from X import *
(c) from X import a, b, c