Python module imports run code!

Опубликовано: 13 Февраль 2023
на канале: Python Morsels
1,381
30

When Python imports a module, it runs all the code in that module.
So if your Python file is meant to be imported as a module, be careful not to put side effects at the top-level of your `.py` file.

Read an article version of this video at https://pym.dev/importing-module-runs...

Find more Python screencasts at https://pym.dev/screencasts/

00:00 A module that defines and prints things
00:23 What happens when you import a module?
01:45 Avoiding import side effects
02:32 When are import side effects acceptable?
03:01 Python runs code when you import a module


На этой странице сайта вы можете посмотреть видео онлайн Python module imports run code! длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Python Morsels 13 Февраль 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,381 раз и оно понравилось 30 зрителям. Приятного просмотра!