Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в Python 3.3
Что он означает?
Ранее, до 3.3 пакетами считались лишь директории, в которых есть файл __init__.py.
Этот файл одновременно являлся свидетельством того, что директория это Python-пакет, и служил "телом" этого пакета. То есть местом, где можно написать код, как это делается внутри модуля. Этот код исполняется в момент импорта пакета, так что его принято называть "код инициализации пакета".
Начиная с версии 3.3 Любая директория считается пакетом и Python будет пытаться использовать любую директорию для импорта.
Конечно, не любую в файловой системе, а только те что находятся в sys.path.
Это значит, что теперь __init__.py нужно делать только если:
🔸 вам требуется создать код инициализации пакета
🔸 нужна совместимость со старыми версиями Python
На мой взгляд это немного упрощает разработку, делает её чище, но с другой стороны убивает некоторую однозначность происходящего.
Например, я создал репозиторий со своей библиотекой и рядом положил код примеров или тестов.
repo_name/
my_library/
__init__.py
main.py
examples/
exam1.py
exam2.py
В этом репозитории пакетом является только my_library, остальные директории это не пакеты, это просто дополнительный код в файлах. Директория examples не добавлена в sys.path, в ней нет рабочих модулей. Но если она лежит рядом с my_library, то Python вполне сможет импортнуть из неё модули, так как посчитает что examples это валидный пакет.
Конечно, пример несколько надуманный. Никто не будет добавлять корень репозитория в sys.path. Но, я думаю, суть ясна. Иногда директория это просто директория а не пакет!
#basic#pep
If you have $10 in your wallet and no debt, you have more wealth than 25% of Americans.
Not because you’re rich… but because debt has so many people buried.
A reminder that sometimes, financial peace isn’t about how much you have—
It’s about how little you owe. 💡
Stay grounded. Stay grateful ❤️
#Countries
🔔@Everything_Science
Chinese government takes its officials and members of their families on prison tours on a regular basis to give officials an introduction to what awaits them if they should engage in corruption.
The tours include meet-and-greets with former government officials who were caught for corruption.
#Countries
🔔@Everything_Science
In Finland, the official World Wife-Carrying Championships have been held since 1992. In this competition, men carry their wives as fast as possible through a long obstacle course. In the end, the winner gets a beer for his wife's weight.
#Countries
🔔@Everything_Science
🌍 Monaco is the most densely populated country on Earth, with over 25,000 people per square kilometer. This tiny city-state squeezes more residents into each square mile than anywhere else. ✨
#population⚡#density⚡#Monaco⚡#countries⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
https://django-localflavor.readthedocs.io/en/latest/
#django- #localflavor is a collection of assorted pieces of code that are useful for particular #countries or #cultures. These are called the “local flavor” add-ons and live in the localflavor package.
🇿🇦🌍South Africa is the 25th largest country in the world.
It borders Namibia, Botswana, Zimbabwe, Mozambique, Eswatini (formerly Swaziland), and Lesotho.
🌊 On the west, South Africa is washed by the Atlantic Ocean, while to the south and southeast it is bordered by the Indian Ocean.
📏 Its area is about 1.21 million sq. km — roughly twice the size of France or three times the size of Germany.
🏞 The country consists of nine provinces.
#Geography#SouthAfrica#Africa#Countries#Facts#DidYouKnow
Lesson 20 of my Uzbek self-study course with audio is here! Learn how to say countries, nationalities and languages in Uzbek. The lesson includes exercises, tables, a crossword puzzle and clear grammar explanations.
https://yep.uz/en/2025/09/lesson-20-countries-nationalities-languages-uzbek/
#uzbeklanguage#learnuzbek#uzbeklesson#languages#nationalities#countries#selfstudy#languagelearning