Вторая по частоте future-функция, которую я использовал, это абсолютный импорт
from __future__ import absolute_import
Что она делает?
Изменения, которые вносит эта инъекция описаны в PEP328
Покажу простой пример.
Допустим, есть такой пакет:
/my_package
/__init__.py
/main.py
/string.py
Смотрим код в my_package/main.py
# main.py
import string
Простой пример готов) Вопрос в том, какой модуль импортируется в данном случае? Есть два варианта:
1. модуль в моём пакете my_package.string
2. стандартный модуль string
И вот тут вступает в дело приоритет импортов. В Python2 порядок следующий: помимо иных источников, раньше ищется модуль внутри текущего пакета, а потом в стандартных библиотеках. Таким образом мы импортнём my_package.string.
Но в Python3 это поведение изменилось. Если мы указываем просто имя пакета, то ищется именно такой модуль, игнорируя имена в текущем пакете. Если мы хотим импортнуть именно подмодуль из нашего пакета то, мы должны теперь явно это указывать.
from my_package import string
или относительный импорт, но с указанием пути относительно текущего модуля main
from . import string
Еще одной неоднозначностью меньше 😎
Подробней про импорты здесь:
https://docs.python.org/3/tutorial/modules.html
#2to3#pep#basic
💎Hey, HEXNation!
⏲ Time for a quick activity with prizes!
• Repost this post in your Telegram story.
• Tag @hexnio and add #HEXN tag to it.
• A few extra words would be a nice touch!
• Click #HEXN in this post to see our global crew.
We'll watch your stories and randomly pick 5 winners to receive a promo-check for 1 $TON each to claim!
LET’S GO! 🚀
*️⃣App | 📈Trade | 🧭Links | ✖️Twitter
💎Hey, HEXNation!
⏲ Time for a quick check-up on how awesome you all are!
Show us your HP farms in your Telegram stories:
• Post your HEXN App in stories.
• Tag @hexn_bot and add #HEXN tag to it.
• Click #HEXN in this post to see our HEXNation!
1-2-3, GO! 🚀
*️⃣App | 💬Chats | *️⃣Website | 𝕏 Twitter
🎥 HEXN Video Makers Contest! 🎥
🗓Contest: July 19th - August 1st
🗓Results: August 3rd
🚀 Total Prize Pool: $10,000! 🚀
Think you’ve got what it takes to make an awesome video about HEXN? Here’s how to join:
1. Create a Video: Make a video about HEXN and upload it to 📱 TikTok, 📱 Instagram Reels, or 📱 YouTube Shorts.
2. Get Views: Reach at least 100,000 views on one of these platforms.
3. Submit Your Entry: Once (and only then) you hit 100k views, send us the link through this Google form: https://forms.gle/gaCT89hNXjjjcf8w6
Rewards:
🎉 $50 for 100,000 views
🏆 $300 for 1,000,000 views
‼️Important:
• Views must be real, we’ll check that! 🔍
• Add the #hexn tag to your video!
• Your video can be in any genre.🎬
🙌We were blown away by your response to our meme contest and realized we have a community full of talented creators! Let’s make HEXN go viral!
🫵Tap THIS & 🔼 Share, so more people can participate!
*️⃣App | 💬Chats | *️⃣Website | 𝕏 Twitter
We are happy to Announce the #HEXN Meme Contest #Winners!
Congratulations #Winners (Twitter Handles)👇!
@ScaredHulk
@cryingrnf
@dionysuz_
@odukunelson
@uonyekiss
@crypto0harry
@greymegawin
@wangshuthian
@mr_h_kumawat
@BOSSSMUDA9
You have won 10$ per each winner. You will receive your reward on the platform 🏆🎉
🎉 Send us a DM with your Registered Email on #HEXN to claim your rewards! DM @MaxAttacker or our Twitter @hexn_io
If your weren't chosen this time around, don't worry! We love memes, so there's more contests on the way.
https://twitter.com/hexn_io/status/1623563743123902465