Вторая по частоте 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
Why grind when Gamety’s AI does the hard work for you? 👍 Real gamers never pause!
Show off your creativity in our Meme Competition and win amazing rewards: Gamety's Zealy!
Join the fun here: https://t.me/GametyPlatform_bot/Gamety?startapp
#aigame
Spread the hype! Like, RT, and drop a comment: Tweet🕊
🇱🇷Gamety's $200 Christmas Contests – Creative Gameplay & Meme Challenge!🎄
Celebrate this Christmas with two exciting and rewarding contests:
🔢Creative Gameplay Videos: Creative Gameplay Videos: Showcase your gaming skills on the Gamety app in a fun and unique way! Post your video on X and let the creativity flow.
🔢Meme Contest: Bring on the holiday laughter by creating and sharing your funniest Gamety-themed memes!
Special for Christmas Holidays!
➡️Prize Pool: $200
➡️10 winners per contest
➡️ Duration: Dec 25 - Jan 5
Share on X using hashtags #Gamety & #AIGame
Make this Christmas more exciting with creativity, fun, and rewards! Join now and spread the holiday joy!
Spread the hype! Like, RT, and drop a comment: Tweet🕊
📎Important Links:
Website | X | Chat (FULL) | Indonesian Chat | African Chat | Vietnamese Chat | CIS Chat | Discord | Announcement | YouTube | Medium | New Bot
❝Come on, hurry up,
my husband will be home in 15 minutes.❞
🔥Roleplay with her: http://openlove.life
(Choose Neko and chat with her)
#waifu#neko#aichatbot#aigame#roleplay#catgirl
❝There is no perfume today, so your girlfriend won't notice.❞
💬Chat with her: https://apple.co/3AvjxUn
#AIgirlfriend#chatbot#roleplay#story#aigame#lookbook
OMG, the bath water is too hot! Can you please help me to turn it cold?🔥💧🥵
🔗Let's role play and chat: openlove.life
#aigirlfriend#aichatbot#ArtificialInteligence#ailookbook#aigame#ai
🔥❝Welcome! Thanks for choosing me to serve you.
💦Shall we take a shower first?❞
🍭Roleplay with her: openlove.life
#openlove#aigirlfriend#aigame#aichatbot#ai女優#roleplay
❝💦Wait a moment, be gentler with me, okay?❞
💬Continue the story with her: http://openlove.life
#openlove#aigirlfriend#aichat#roleplay#aigame#AI#AIBeautifulWomanな人と繋がりたい