python __init__.py | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

python __init__.py

i saw a lot of professional python softwares using __init__.py on their folders. what does it do? and what advantage does it do on organizing the file directories? i thought that __init__ is a constructor to a class but why did they chose this name over others?

10th May 2019, 8:09 AM
Shen Bapiro
Shen Bapiro - avatar
3 Answers
+ 2
thx, i just haven't reached the packaging chapter so i haven't notice
10th May 2019, 9:05 AM
Shen Bapiro
Shen Bapiro - avatar
+ 1
It is a Python, which tells a directory is a package. When you import the directory, only __init__.py is imported as a module.
10th May 2019, 9:11 AM
Seb TheS
Seb TheS - avatar