Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
🚀 To celebrate the partnership with @AEON_Commuinty, the leading crypto payment framework, built for AI to drive intelligent, automated payments across Web3 and simplify how crypto works in real life, we're hosting a GIVEAWAY! 🎉Total $700 Up For Grabs!
⏰May 1st, 10:00 AM - May 20th, 10:00 AM (UTC)
1️⃣$200 raffle for qualified #Galxe participants
2️⃣$500 rewards via AEON Pay for TOP and FCFS consumers
Consume $UXLINK to cover daily expenses (Each transaction must over $5).
👀Stay tuned for the upcoming announcement! In the meantime, feel free to take a sneak peek here 👉https://t.me/aeon_pay_bot
The competition is heating up, and it's time to take your skills to the next level in our #TON Capital #Galxe Campaign!⚡️
With more tasks, bigger rewards, and an even tougher playing field, the challenge is yours to conquer.
💪 Complete missions, accumulate points, and rise to the top of the leaderboards for your chance to claim extraordinary rewards. From challenges and quizzes to community actions, every task pushes you closer to victory.
🎁 The Best Will Be Rewarded:
🏆A $1000 USDT prize pool awaits the Lucky 100 on our Galxe campaign leaderboard
🏅Exclusive badges for the Lucky 500 contributors ( Galxe Explorer + Guaranteed Whitelist)
🎯Access to the Season 1 Expedition Grand Prize, worth up to $50,000 and 88.8m $TONCAP!
Join TON Capital Galxe Campaign -- https://app.galxe.com/quest/SAw9YJRiY3VF2oevPJpa3K/GCWPWtKwCQ
Show us what you’ve got and seize your opportunity to be part of something great in the world of TON and Web3.
⚡️The future is yours to shape!
🎉 Solana Leveling #Airdrop on #Galxe🎉
We’re giving away $5 to 10 lucky winners 💸
✅ Complete simple social tasks
✅ Join the Solana Leveling community
✅ Stay updated with the best Solana insights
👉 Enter here:https://app.galxe.com/quest/AygxpG3nDj4VfTNkmsTrpN/GCUxJt6zNX
🆕 Galxe now fully supports #TokenPocket login!
👉https://extension.tokenpocket.pro/
Galxe is the leading platform for building the Web3 community.
🔥Follow TokenPocket Space and Get Ready for the #TokenPocketChristmas on #Galxe!
👉https://galxe.com/TokenPocket
Details:
👉https://twitter.com/Galxe/status/1729918366012600584
👉https://twitter.com/TokenPocket_TP/status/1730068829311774726
⚡️Electra launches a quest on Galxe!
We are pleased to announce that🚀Electra launches an exciting $ELT token reward campaign on the #Galxe platform!
This means that Airdrop is just around the corner!
🏆
💵 As part of this campaign, you have the opportunity not only to earn $ELT tokens, but also to participate in prize draws in $USDT, unique NFTs and tokens from top partners🤝Electra!
Complete quests, follow the news and get ready for the $ELT airdrop!
➡️Take part in the campaign
#Electra#Airdrop#DeFi#Web3
Become an APTOS and SUI supporter and reach new peaks⛰
Go to Galxe 👇
https://galxe.com/apstation/campaign/GCLYeU42e1…
#Aptos#Galxe#AptosEcosystem#Sui#SuiEcosystem
https://twitter.com/CetusProtocol/status/1621413895578726400?s=20&t=idtvF7UcG6zXWiw2NhUUdA
@everyone
🔥Airdrop – Empeiria x Leap Wallet ✅
💠Reward:Empe Micro Node (worth $50) – Grants access to EMPE token staking rewards. Claiming starts after TGE.
☀️Airdrop Link :- Click Here
⚙️How to Participate?
♦️Jointheevent on Galxe
♦️Complete all listed quests
♦️Connect your wallet & verify tasks
♦️Secure yourEmpe Micro Node reward
📌Note:Limited-time event – don’t miss your chance to get early staking access with Empeiria
®Note - Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens.
#Empeiria#LeapWallet#Galxe#Airdropcomic#CryptoRewards#Web3