What does '__init__.py' do in Python?

preview_player
Показать описание
In today's video we're going to be learning about __init__.py and what it actually does in Python.

▶ Become job-ready with Python:

▶ Follow me on Instagram:
Рекомендации по теме
Комментарии
Автор

Thanks for covering the role of __init__.py in the import of a module. Because a lot of video tutorials skip this information.

umka
Автор

This is a great start on this topic. There arent actually a lot of youtube videos about this topic, and its hard to find information. Would appreciate a follow up that went more into detail, if you can. For instance: what exactly happens when you import things in the __init__.py file. What sort of start up logic do you need to do. What is the appropriate use of this file etc....

arkie
Автор

you should mention the difference between having _init_.py and not having one in your module directory

BohonChina
Автор

that one class I ignored, it was this one in 2021. i got it now 😂 thanks for this!

danialothman
Автор

Thanks for this basic tutorial about imports, could it be possible to make a video about imports between modules in the same package ? cause this is always a pain in the a** to know how to do these correctly and everyone seems to use different tricks when searching for solutions on the net. That would be a really helpful video

dragweb
Автор

Good job! Pycharm was a nice touch since that’s the environment that many use.

mikecanaday
Автор

This is amazing. Im completely rebuilding an app Im working on based on this!!!

purplemonkeydishwasher
Автор

Crystal clear. Thank you for explaining it very simpel!

petsandpaws
Автор

This is so helpful and clearly explained! Thank you very much!

lisaw
Автор

simple and to the point, thank you :)

a_maxed_out_handle_of__chars
Автор

You're awesome.
This one has a lot of great tips

Wh-al-es
Автор

The __all__ dunder method is something i didnt know yet. Neat

EquiliMario
Автор

It would have been interesting to see the behavior of __init__.py when importing the same package from multiple different modules within your project. If I'm not mistaken, the __init__.py will be called only once (the first time any import statement is used).

FighterAceee
Автор

I use "__init__.py" also for importing all the libraries that I will import in the submodules. And then, in the submodules, I use "from . import <something>". I don't know if it's useful, I wanted to have organized imports.. Does it make sense?

giocic
Автор

FYI, from what I can tell, VS Code doesn't change the directory icon when you declare it to be a module (by adding dunder init . py).

GregMeece
Автор

Thank you indeed... Extremely clear, concise... Thank you ...

nobody
Автор

I enjoy your videos a lot! Keep posting😊

ml_with_pranay
Автор

I love you, great videos, and please keep going.😁😁😁

davidlu
Автор

aveasome thank you, would like to learn more about it :D

_Garm_
Автор

i didnt even know i needed to know this

PennyEvolus