filmov
tv
What should you write into the __init__.py file? 2MinutesPy

Показать описание
In this video, we will discuss what code and data you can put into your __init__.py file in Python.
You know without this file, Python won't recognize the directory as a package, and you won't be able to import its modules. So, the question is, “What to include” in your __init__.py file?
Well, the list is endless, but here are something you can include:
- Import specific functions and submodules
- Code that you want to execute when the package is initialized
- __all__ variable to control the functions and variable imported when someone uses wildcard import statement
- Module's information
- Logging capability
- Environment variables
- External connections
- and much more...
Chapters:
⏩ 0:00 Intro
⏩ 0:24 Directory structure and __init__.py file
⏩ 0:50 What to include in __init__.py file
⏩2:53 Outro
✨More on 2MinutesPy👇👇
@2MinutesPy
#__init__.py #init #__init__ #pythonpackage #package #python #pythonprogramming #module #script #2minutespy
You know without this file, Python won't recognize the directory as a package, and you won't be able to import its modules. So, the question is, “What to include” in your __init__.py file?
Well, the list is endless, but here are something you can include:
- Import specific functions and submodules
- Code that you want to execute when the package is initialized
- __all__ variable to control the functions and variable imported when someone uses wildcard import statement
- Module's information
- Logging capability
- Environment variables
- External connections
- and much more...
Chapters:
⏩ 0:00 Intro
⏩ 0:24 Directory structure and __init__.py file
⏩ 0:50 What to include in __init__.py file
⏩2:53 Outro
✨More on 2MinutesPy👇👇
@2MinutesPy
#__init__.py #init #__init__ #pythonpackage #package #python #pythonprogramming #module #script #2minutespy
Комментарии