Вторая по частоте 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
#Sentiment notes that the activity of #BTC discussion on social media has risen to a 4-month high, there is a serious panic among the crowd. Such depressive indicators in the moods usually preceded the rebounds.
⚡️ Sentiment notes a decrease in the number of wallets with a non-zero balance 🪙#BTC, which may mean that some participants will enter the cache before the US elections. The experts of #Sentiment consider this development of the situation to be #bullish for #BTC after the elections are held...
#Sentiment notes a sharp rise in bullish sentiment in #Solana
there are rumors that #Apple (#AAPL) is starting to use the Solana — Sentiment blockchain
🤣Ethereum Fear & Greed Index has dropped to 13, signaling Extreme Fear across the market.
市場情緒跌入 極度恐懼區間,代表短期資金風險偏好明顯下降,投資人情緒趨於保守。
#Crypto#以太坊#币圈#区块链
⚡️ 歷史上極度恐懼區域,往往出現在市場接近階段性底部時,但短線波動仍可能持續。
#Ethereum#Markets#Sentiment
———
👇⭐️👇
🤣留言分享觀點
🥲👇