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