Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
Upcoming Airdrops Alert! 🚀
Hey everyone! 🎉 If you missed out on the Dogs airdrop, don’t worry! There are some exciting new airdrops coming up that you won’t want to miss. Check out these potential big earners:
1. Major🌟
1. X Empire 🏰
3. Cats🐈
4. Memefi🎭
-Confirmed Listing Date: October 9th
-All WILL BE LISTED IN ABOUT A MONTH TIME , SO JOIN AND GET FREE TOKENS BEFORE ITS TOO LATE!!!
#Airdrops
🎁 The #giveaway with 4EVERLAND has officially ended! A big thank you to #TokenPocket for their support and to all participants.
👇🏻Keep an eye out for upcoming thrilling #airdrops and don't forget to claim your $4EVER points at: https://dashboard.4everland.org/quest/tp
🥳We are thrilled to announce that UXLINK has made strategic partnership with @LumozOrg
to build Social Growth Layer(SGL) together!
Our ecosystem fund @UFLY_Labs
will invest @LumozOrg and we will empower Lumoz social growth & business development globally especially in Japan and Korea market & community.
💰Lumoz native token $MOZ will be #TGE on CEXs soon and we will make ONE MILLION dollar value #Airdrops to qualified $UXLINK holders and stakers!
Lumoz is the leading Modular Compute Layer for ZK & AI. Lumoz uses PoW mining mechanism to provide computing power for Rollup, ZK-ML and ZKP verification.
Please stay tuned for our updates!❤️
Channel: Legit Airdrop ️
Members: ~142.24K
💢 Username: @legit365airdropss
Description:
Welcome dear subscribers! We will do our best to share the legit airdrop campaigns timely. If You Need Any Airdrop Project Promotion Then Contract here @Legit365airdrop1 Buy ads: https://telega.io/c/legit365airdropss
🏷 Tags: #airdrop
#airdrops#cryptocurrency
https://telegramchannels.me/channels/legit365airdropss
$ORB and $MOZ #Airdrops done just now, #UXLINKseason2 stakers please kindly check your wallet address to get the token❤️https://arbiscan.io/address/0x0698e377ca9dbfb5c77503d611c6f1f38cf46ba2
#Airdrops Are Making Millionaires In Crypto – Here’s How [Full Guide Cosmos, LUNA & More]
#cryptogemtokenshttps://cryptogemtokens.com/airdrops-are-making-millionaires-in-crypto-heres-how-full-guide-cosmos-luna-more/
Phantom Wallet Dismisses Token Rumors
Phantom Wallet team clarifies: no plans for a native token or airdrop. Focus remains on improving the token and app discovery mechanism. More details: Read here
#Phantom#airdrops#wallets#Crypto#VC