Вторая по частоте 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
🪐 Discovered in 2013, asteroid 2013 TX68 drew attention due to its unpredictable orbit, which allowed it to pass within a few million kilometers of Earth—close enough that its next flyby in 2046 will be closely watched. This space rock is roughly 30 meters wide, similar in size to the Chelyabinsk meteor, and while it's not currently on a collision course, its uncertain path highlights the challenges of tracking smaller, potentially hazardous asteroids. ✨
#asteroids⚡#nearearth⚡#planetarydefense⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Asteroid (4660) Nereus is a near-Earth object about 330 meters wide, famous for its frequent close approaches to our planet due to its elongated orbit around the Sun. While it poses no immediate danger, Nereus occasionally comes within just a few million kilometers of Earth, making it one of the more closely watched space rocks for future planetary defense planning. ✨
#asteroids⚡#nearearth⚡#planetarydefense⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Asteroid (29075) 1950 DA is one of the most closely monitored potentially hazardous asteroids, as it has a slim chance of impacting Earth in the year 2880. This kilometer-sized space rock spins so fast—completing a rotation every 2.1 hours—that its own gravity barely holds it together, making it a real cosmic oddity among dangerous near-Earth objects. ✨
#asteroids⚡#planetarydefense⚡#spacehazards⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The asteroid (410777) 2009 FD is a near-Earth object roughly 472 meters wide, with an orbit that brings it uncomfortably close to our planet every few decades. Although calculations show it poses no immediate threat, its path is closely watched because even moderate-sized objects like 2009 FD can cause widespread devastation if they ever collide with Earth. ✨
#asteroids⚡#planetarydefense⚡#nearearthobjects⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 In 2013, astronomers tracked asteroid (367943) Duende, a 30-meter-wide space rock that passed just 27,700 kilometers above Earth's surface—closer than many weather satellites. Duende’s near miss was remarkable not only for its proximity, but because it approached from the Sun’s direction, making it hard to spot in advance and highlighting the ongoing challenge of detecting small but potentially hazardous asteroids before they pass close to our planet. ✨
#asteroids⚡#duende⚡#planetarydefense⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The asteroid (2011) AG5, classified as a near-Earth object, made headlines because it once had the highest estimated probability of impacting Earth in the 21st century. Thanks to ongoing observations, scientists have refined its path, showing it will safely pass by our planet in 2040, but its close approach—just 1.1 million kilometers away—demonstrates how carefully even modest-sized asteroids must be tracked to protect Earth from unexpected cosmic threats. ✨
#asteroids⚡#nearearthspace⚡#planetarydefense⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries