0

Is __init__.py file is a module ? I am learning python and come across packages and modules and i have one doubt that weather __init__.py file can be consider as module Since every python file is module so can we consider __init__.py as module ?

timgeb
  • 76,762
  • 20
  • 123
  • 145
Divesh Sankhla
  • 53
  • 2
  • 13

1 Answers1

2

According to the official glossary a module is

An object that serves as an organizational unit of Python code. Modules have a namespace containing arbitrary Python objects. Modules are loaded into Python by the process of importing.

Which (imho) borders on gibberish for saying "module objects or files with Python code."

Since even an empty __init__.py file contains valid Python code, and you can import it via import __init__, it would technically be considered a module. I don't know how this knowledge could be useful.

timgeb
  • 76,762
  • 20
  • 123
  • 145