0
what is __init__.py please give me example
4 Antworten
+ 3
"The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file"
https://docs.python.org/3/tutorial/modules.html?highlight=__init__#packages
+ 3
__init__.py*
*__init__.py is a constructror of a package*.
*package is a directory of modules*.
*module is a file of code.
module can be ran from other script as:
import module_name
*package's certain modules are ran from other script as:
import package_name.module_name
*package's __init__.py is ran from other scripts as:
import package_name
0
thank