Вторая по частоте 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
Национальная премия «Хрустальный компас» — одна из самых престижных наград в области географии, экологии и смежных наук!
🏆 В 2026 году уникальные хрустальные статуэтки будут вручены уже в 14-й раз. Лауреатами станут авторы выдающихся исследований и проектов, а также организации и инициативные группы, внесшие значимый вклад в сохранение природы, культурного и исторического наследия.
👩🎓 К участию приглашаются:
— научные и образовательные учреждения
— творческие союзы и организации
— общественные деятели и инициативные группы
— компании и частные лица из России и других стран.
📋 Приём заявок открыт до 10 февраля 2026 года.
Не упустите шанс стать частью международного сообщества, объединяющего исследователей, путешественников и защитников природы более чем из 50 стран мира!
🔗 Подробная информация и подача заявок: https://clck.ru/3PEnsz
#ХрустальныйКомпас#RGO#Наука#Экология#Geography#CrystalCompass#Наследие#Премия
🇷🇺🌊🌊🌊
🇮🇳 On September 2, Ratish Nair, Honorary Consul of Russia in Trivandrum (Karnataka, India), began a journey along the route of Afanasy Nikitin. The ambitious project is dedicated to the 555th anniversary of the famous "Journey Beyond Three Seas".
📍 The starting point of the journey was the embankment named after the famous Russian traveler Afansy Nikitin in Tver.
⚡️ Ratish Nair met Senator of the Federation Council of Russia from the Tver Region Lyudmila Skakovskaya and Rector of Tver State University Sergei Smirnov.
I am sure that this is a wonderful undertaking - repeating the route of the Tver merchant Afanasy Nikitin. This will help educational and outreach work, draw attention to the traveler's personality, and strengthen ties between our countries. I am sure that in our country, preserving and studying history is one of the most important areas of work,
the Senator emphasized.
Even in India, not everyone knows that Afanasy Nikitin is the first foreigner who came to our country for peaceful purposes. Friendly relations between India and Russia should be strengthened. This is the main goal of my trip. I am sure that the trip, repeating the path of the Russian traveler, will help to show Russia as it is and open it to foreigners without speculation and fakes,
said Ratish Nair.
🗣The meeting participants discussed the opening of Russian online educational courses in Russian in the Indian state of Karnataka, as well as other educational initiatives.
🗺 The head of the Russian House in Trivandrum will visit four more countries after Russia. His route, like 555 years ago, will lie from Tver to Astrakhan along the Volga river, then by car to Derbent, from there to
🇦🇿Azerbaijan, then to
🇮🇷 Iran, from there by plane to
🇴🇲 Oman, and then to
🇮🇳 India.
This project is organized by #Rossotrudnichestvo, the Russian Ministry of Foreign Affairs (#MFA), the #RusskiyMirFoundation, and the Russian Geographical Society (#RGS, #RGO), with #Rosatom and #Sber as partners.
#RussianHouse#RussianHouseTrivandrum#JourneyBeyondThreeSeas
#Voyage555