Вторая по частоте 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
On 9 June, International Archives Day is celebrated around the world. Often these documents are classified for decades. Only the next generation can learn about the reasons and details of the event in a reliable way.
Our post is about the nuclear bombing of Hiroshima, which American President Harry Truman advocated. The declassified archives make it clear the bombing of Japan was to be a rehearsal for a possible nuclear war between the US and the USSR. Watch the entire film Atomic Message for details.
#history#disasters
Follow: https://t.me/rtdocumentary
🌎 A colossal tsunami struck Japan’s Sanriku coast in 1896, triggered by an undersea earthquake. Towering waves up to 38 meters high destroyed villages and claimed nearly 22,000 lives, prompting global advances in seismic and tsunami warning systems. ✨
#tsunami⚡#history⚡#disasters
👉subscribe Interesting Planet
🌎 At the heart of Africa, Lake Nyos hides a deadly secret—an underwater layer of carbon dioxide gas that once erupted, suffocating everything nearby in 1986. This rare “limnic eruption” happens when gas builds up at depth and suddenly bursts to the surface, releasing an invisible, odorless cloud with devastating effects. ✨
#volcanoes⚡#disasters⚡#geology
👉subscribe Interesting Planet
🌍 In 2022, two major floods in Pakistan covered about one-third of the country, displacing over 33 million people—one of the largest human impacts from a single natural disaster this decade. ✨
#disasters⚡#flooding⚡#climate⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In 2021, a record-breaking heatwave in western Canada triggered hundreds of wildfires, generating so much smoke it traveled thousands of kilometers and reached northern Europe. ✨
#disasters⚡#wildfires⚡#climate⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 In 2021, Europe's Aegean wildfires generated smoke that reached as far as the North Pole—a rare journey showing how natural disasters can have effects thousands of kilometers away. ✨
#disasters⚡#wildfire⚡#atmosphere⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Tonga eruption in 2022 sent shockwaves around the globe so powerful they circled Earth several times. Its volcanic plume was the tallest ever recorded, reaching almost 58 kilometers high. ✨
#volcano⚡#eruption⚡#disasters⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Earth’s largest volcanic eruption in the past 70,000 years was Toba in Indonesia. Its explosion formed a lake-filled crater 100 kilometers wide and sent ash around the globe. ✨
#disasters⚡#volcano⚡#eruption⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Tornado Alley in the central United States experiences more tornadoes than anywhere else on Earth. Warm and cold air mix here, making intense storms common each spring and early summer. ✨
#tornadoes⚡#storms⚡#disasters⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Super Typhoon Haiyan in 2013 set a record for the strongest tropical cyclone to make landfall, with winds reaching 315 km/h. Its extreme force reshaped entire coastlines in the Philippines. ✨
#disasters⚡#typhoon⚡#wind⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The 2018 Sulawesi earthquake in Indonesia triggered a rare "soil liquefaction," turning solid ground into a flowing sludge that swallowed entire neighborhoods beneath muddy waves. ✨
#disasters⚡#earthquake⚡#liquefaction⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The 2004 Indian Ocean tsunami sent waves up to 30 meters high across 14 countries. This natural disaster traveled as fast as a jet plane, reaching Africa in mere hours. ✨
#tsunami⚡#disasters⚡#waves⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍