Вторая по частоте 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
🚀BIG ANNOUNCEMENT!
🚀
Bitcoin💸 just achieved a monumental milestone, breaking the 💵1 trillion market cap! 🎉📈 With the continuous surge in ATH🔝 (All-Time High) values every day, we can't help but capitalize on this golden opportunity.
📆 SAVE THE DATE: THIS SUNDAY
⌛️Time : 17:00 PM (GMT)
🚀 Pump Target: At least 700%
💰Duration: The pump is expected to last for days.
This isn't just a pump; it's a chance to ride the wave of success in the booming crypto market.
Turn on your notifications and join us on Sunday for an epic pump that could bring massive profits.
Let's make this one for the record books! 💸#BitcoinPump#CryptoSuccess
Got any Questions? @RobertMillercrypto
🔥 Mastercard, Citigroup, and JPMorgan Chase join forces to pilot shared ledger technology for Tokenized Assets settlement processes, with the goal of enhancing speed and security in cross-border transactions. This collaboration could transform the financial sector by enabling diverse asset types to settle on a unified platform.⭐️🌐
#Cryptoassets
#Cryptosuccess
#Blockchainrevolution
🎉SLEX Exchange HITS Top-50 on CoinPaprika! 🚀
💫SLEX Exchange made it into the Top-50 among over 300 cryptocurrency exchanges on CoinPaprika! This achievement highlights our dedication to providing top-notch trading services and robust security.
🤝Thank you to SLEX community for your trust and support. This achievement is as much yours as it is ours!❤️
🔗Check out our ranking: SLEX on CoinPaprika
🦾Come aboard SLEX - wheee crypto and commodity trading meet innovative features. Grow and profit with us! ☄️
#SLEX#Top50#CoinPaprika#CryptoSuccess
Website| Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🚨Crypto Trading Guide for Beginners🚨
Ready to master crypto trading? Join Ekta Mourya from FXStreet as she breaks down how to stop gambling and start building wealth with a structured plan! 💥
Key Insights:
- Stop guessing, understand market cycles 📉
- Avoid 3 common mistakes beginners make ❌
- Use the Crypto Fear & Greed Index to your advantage 🤑
- Top-down analysis with simple tools like RSI & Moving Averages 📊
Start trading like a pro today.
Watch now! 👉https://www.youtube.com/watch?v=R8aAPHvHiKU
#CryptoTradingGuide#BitcoinForBeginners#FXStreet#CryptoSuccess#SmartMoneyConcepts
🚨Crypto Trading Guide for Beginners🚨
Ready to master crypto trading? Join Ekta Mourya from FXStreet as she breaks down how to stop gambling and start building wealth with a structured plan! 💥
Key Insights:
- Stop guessing, understand market cycles 📉
- Avoid 3 common mistakes beginners make ❌
- Use the Crypto Fear & Greed Index to your advantage 🤑
- Top-down analysis with simple tools like RSI & Moving Averages 📊
Start trading like a pro today.
Watch now! 👉https://www.youtube.com/watch?v=R8aAPHvHiKU
#CryptoTradingGuide#BitcoinForBeginners#FXStreet#CryptoSuccess#SmartMoneyConcepts