Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
#African experts meet in #Rwanda for continental textile standardization
African experts have convened in the Rwandan capital #Kigali for the Technical Committee (#TC 53) meeting on the standardization of textiles, textile products, and accessories.
The forum, which ran from Tuesday to Friday, focused on finalizing agreements and establishing key standards and labeling systems for the textile sector, with the aim of strengthening trade and supporting economic growth within the continent's textile industry.
Hermogene Nsengimana, secretary general of the African Organisation for Standardization (#ARSO), highlighted that Africa still faces a significant gap in developing common quality standards.
He added that currently, only about 25 percent of the standards required for all products in the African common market have been established.
Nsengimana said that ARSO has set a target to significantly reduce this gap within the......
https://english.news.cn/africa/20260307/6634375ed4a4474cab2c20d0c4a31253/c.html
🚨Game : TC Games
🤑Refer: High Level Commission
🛃Minimum Deposit : 300Rs
📅Minimum Withdraw : 110Rs
🖥Earn daily : 500-10keasily
🤖Game Link: Join Here
📝Guide:
🔘 Register Using Mobile Number
🔘 Play game and Withdraw and earn High money
🧿Info
🔘 Contact Telegram Support
🔘 Join Telegram Prediction Group1 and Group2
🔘 Only 4-7 Level Sure winning
🔘 Want to become an agent and bonus Contact
🔴Note: Please do your own research (DYOR) before joining to any project.Don't send any fee or penny without doing own research.
#TCgames#TcLottery#Indian#inr#TC#Sponsored#Ad
📈Game : TC Games
💎Refer: High Level Commission
💳Minimum Deposit : 11 USDT/300Rs
💰Minimum Withdraw : 11 USDT/110Rs
🔸Earn daily : 500-10000USDT easily
🤖Game Link: Join Here
📝Guide:
🔘 Register Using Mobile Number ( if you are from Countries other than AFG,IND, PAK, BAN you can simply put your number with any Country code no need of OTP verification)
🔘 Play game and Withdraw and earn High money
📄Info
🔘 Contact
✉️Telegram Support
🔘 Join
✉️Telegram Prediction Group1 and Group2
🔘 Only 4-7 Level Sure winning
🔘 Want to become an agent and bonus Contact
🎁Note: Please do your own research (DYOR) before joining to any project.Don't send any fee or penny without doing own research.
#TCgames#TcLottery#Indian#inr#TC#Sponsored#Ad#USDT