Вторая по частоте 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
An elephant’s trunk 🐘 is an amazing example of evolutionary development 🧬. It is a combined nose and upper lip that lengthened as the elephant’s ancestors became taller and their tusks grew bigger. With its heavy head, it needed an easy way to reach the ground.
@googlefactss#evolution
Автопортреты Joni Mitchell, которые стали обложками её релизов
• Clouds
• Ladies Of The Canyon
• Wild Things Run Fast
• Turbulent Indigo
• Taming The Tiger
• Both Sides Now
• Travelogue
• Dreamland
• The Reprise Albums (1968-1971)
Митчелл часто говорила, что она «художник, который выпускает песни».
Нельзя не заметить очевидную отсылку на другого художника, который за жизнь нарисовал с десяток автопортретов, — Винсента Ван Гога с отрезанным ухом на обложке «Turbulent Indigo».
#evolution
🌍 The island of New Caledonia is a biodiversity hotspot where ancient plants like the rare Amborella tree represent some of Earth’s oldest surviving flowering lineages, found nowhere else. ✨
#biodiversity⚡#islands⚡#evolution⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌎 The star-nosed mole detects prey in total darkness using its unique nose, covered in 22 finger-like tentacles packed with touch sensors. This extraordinary adaptation lets it identify and eat tiny insects and worms faster than any other mammal, even underwater. ✨
#animals⚡#adaptation⚡#evolution
👉subscribe Interesting Planet
🌎 The saiga antelope’s enlarged, drooping nose acts as a built-in air filter and cooler on the Central Asian steppes. When alarmed, herds can stampede at speeds up to 80 kilometers per hour. ✨
#animals⚡#evolution⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 The shoebill stork stands over 1.2 meters tall and has a massive, shoe-shaped bill up to 24 centimeters long. Native to East African swamps, this solitary bird hunts lungfish, frogs, and even baby crocodiles. ✨
#animals⚡#biodiversity⚡#evolution
👉subscribe Interesting Planet
👉more Channels
🌎 The platypus baffles scientists as it lays eggs like a reptile but produces milk and has fur like a mammal—a rare mix found in no other living animal. This odd, Australian creature even senses prey underwater using electroreceptors in its bill. ✨
#animals⚡#evolution⚡#Australia
👉subscribe Interesting Planet
🌎 Horseshoe crabs have remained virtually unchanged for about 450 million years. Despite their name, they are more closely related to spiders than to true crabs. Modern horseshoe crabs can be found along the Atlantic coast of North America and in Southeast Asia. ✨
#animals⚡#evolution⚡#fossils
👉subscribe Interesting Planet
👉more Channels
🌎 Living fossils like the chambered nautilus and horseshoe crab have changed little for hundreds of millions of years. The nautilus dates back over 500 million years, and its closest extinct relatives include ammonites, which died out with the dinosaurs. ✨
#evolution⚡#fossils⚡#animals
👉subscribe Interesting Planet
👉more Channels
🌎 Living fossils like the giant freshwater stingray and the Australian lungfish have remained almost unchanged for over 100 million years, surviving dramatic changes in Earth’s environment. The horseshoe crab’s body plan is so ancient, it first appeared 450 million years ago. ✨
#evolution⚡#fossils⚡#animals
👉subscribe Interesting Planet
👉more Channels
🌎 Some ancient animals have survived unchanged for millions of years. The coelacanth, once thought extinct, first appeared 400 million years ago and still swims deep ocean waters today. The horseshoe crab dates back over 450 million years, predating dinosaurs and even trees. ✨
#evolution⚡#fossils⚡#animals
👉subscribe Interesting Planet