Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
Big news for Apple users! 🍏✨ Did you hear? Apple has finally allowed emulators on iOS, and Delta stands out as one of the best out there! 🎮 Have you given it a try yet? Share your thoughts below! #iOS#Emulators#Delta
🌍 The Mississippi River Delta’s vast freshwater wetlands act as a natural filter, removing pollutants and buffering storm surges. These shifting marshes shelter over 400 species of fish and wildlife. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Okavango Delta in southern Africa floods seasonally with rainwater from distant highlands, creating vast, ever-shifting freshwater wetlands that support hundreds of rare animal species. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Danube Delta in Eastern Europe contains over 30 distinct types of freshwater wetlands, making it one of the most biodiverse delta systems in the world outside the tropics. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Ethiopia’s Lake Tana is the source of the Blue Nile and is surrounded by freshwater wetlands that support dozens of bird species found nowhere else, making it a hotspot for endemic wildlife. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 River deltas like Vietnam’s Mekong and the Mississippi in the US form complex freshwater wetlands, creating twisting channels and islands that shelter rare fish, birds, and vital crops. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Wetlands in the Siberian taiga freeze solid each winter, yet come alive in spring to host millions of migrating birds. These seasonal deltas become some of the world’s richest breeding grounds. ✨
#wetlands⚡#delta⚡#migration⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Okavango Delta in Botswana is one of the few major river deltas that forms entirely inland, creating a lush wetland oasis in the middle of the Kalahari Desert. ✨
#rivers⚡#wetlands⚡#delta⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Sudd in South Sudan is the largest freshwater wetland in the Nile basin. During flood season, its floating reeds can form islands that drift for kilometers across the swamp’s surface. ✨
#wetlands⚡#delta⚡#Africa⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Some freshwater wetlands and deltas trap so much carbon in their soil that, hectare for hectare, they store more than most forests—making them powerful natural climate regulators. ✨
#wetlands⚡#delta⚡#carbon⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Florida Everglades, a vast freshwater wetland, is the only place on Earth where alligators and crocodiles coexist in the wild, thanks to its unique mix of habitats and water conditions. ✨
#wetlands⚡#delta⚡#wildlife⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍