Вторая по частоте 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
❌🟠 Los Giants no anticipan hacer un contrato de nueve cifras para Tatsuya Imai ni para ningún otro lanzador en el mercado esta temporada baja, según Andrew Baggarly.
#️⃣#Giants
🗞 | t.me/MLB_Daily
🏥🌉 Los Giants están colocando a Logan Webb en la lista de lesionados con bursitis en la rodilla derecha, según Alex Pavlovic de NBC Sports Bay Area.
Es la primera vez que Webb está en la lista de lesionados desde 2021.
#Giants#LWebb
🗞 | t.me/MLB_Daily
🟠🤠 Según varios informes, incluidos los de Mark Feinsand de MLB.com, los Giants y el lanzador derecho Tyler Mahle han acordado un contrato de un año.
#️⃣#Giants#Mahle
🗞 | t.me/MLB_Daily
🟠 Según Ken Rosenthal, se informa que los San Francisco Giants están cerca de contratar a Tony Vitello, entrenador principal de Tennessee, como su nuevo manager.
#️⃣#Giants#Vitello
🗞 | t.me/MLB_Daily
🌎 The coconut crab is the world’s largest land-dwelling arthropod, able to crack open coconuts with its powerful pincers. These giant crabs live on islands across the Indo-Pacific, and their climbing and shell-breaking skills help them access food that other animals can’t reach. ✨
#animal⚡#giants⚡#adaptation⚡#islands
👉subscribe Interesting Planet
🪐 Unlike Earth and Mars, giant planets like Jupiter and Saturn do not have solid surfaces—their thick outer layers are made mostly of hydrogen and helium gas, which gradually becomes denser toward the center. These gas giants can have dozens of moons and faint ring systems, and their powerful magnetic fields—especially Jupiter’s, which is the strongest of any planet in our solar system—can trap charged particles, creating intense radiation belts that glow in radio waves. ✨
#Jupiter⚡#Saturn⚡#giants⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Jupiter, the largest planet in our solar system, is so massive that it has over twice the combined mass of all the other planets put together. Its rapid rotation—completing one spin every 10 hours—causes it to bulge noticeably at the equator, creating a distinct flattened shape unlike the more spherical profiles of smaller planets. ✨
#Jupiter⚡#giants⚡#rotation⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Saturn’s rings are made mostly of icy particles ranging from the size of grains of sand to mountains, but what’s remarkable is that these rings are incredibly thin—often only about 10 meters thick compared to their width of up to 282,000 kilometers. Despite their vast size, the rings would still fit comfortably within the gap between Earth and the top of our atmosphere if laid flat. ✨
#Saturn⚡#rings⚡#giants⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels