Вторая по частоте 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
Live: Dazzling nightscape at Shanghai's Yangpu Riverside
As APEC's host again after a 12-year interval, China is holding the Second Senior Officials' Meeting and related #APEC meetings in Shanghai. As night falls, the Yangpu Riverside in Shanghai comes alive with dazzling lights. The shimmering river reflects rows of towering skyscrapers, blending waterfront tranquility with the bustling glamour of a global metropolis. Bright neon lights glimmer along the bank, and gentle river breezes brush past the promenade, painting a picture of Shanghai's modern prosperity and timeless elegance.
via CGTN
#APEC 2024 : les point clés de la dernière journée du sommet
Le sommet de l'APEC s’achève par une ultime réunion dans la capitale du #Pérou. Une déclaration finale doit être adoptée à l'issue du sommet. Les détails avec notre envoyé spécial sur place, Igor Kourachenko.
RT en français • Osez questionner !
#APEC 2024 : les points clés de la deuxième journée du sommet
La deuxième journée du sommet de l’APEC a commencé au #Pérou. Plus de détails avec notre envoyé spécial Igor Kourachenko, qui est sur place.
RT en français • Osez questionner !
🌐APEC Ministers Commit to Trusted AI and Inclusive Digital Growth
APEC digital and AI ministers convened for the first time in Incheon, Republic of Korea, issuing a joint statement that redefines regional priorities for AI governance. The meeting underscored a united commitment to responsible digital transformation and the development of trusted AI systems aligned with economic and societal needs.
The ministers identified three focal points: accelerating AI innovation to solve socio-economic challenges, expanding equitable digital connectivity, and building a secure, transparent AI ecosystem. Korea’s initiative to launch a dedicated APEC AI program by the end of 2025 was met with strong support, positioning the region to lead on practical, multilateral AI governance.
#AIandLaw#APEC#AIRegulation#AsiaPacificAI
🎙 Foreign Minister Sergey Lavrov’s video address to the 9th international conference "Russia and China: Cooperation in a New Era" (May 30, 2024)
💬 I am delighted to welcome the organisers of and participants in the 9th international conference "Russia and China: Cooperation in a New Era".
Most recently, Russia's President Vladimir Putin paid a state visit to China, which definitely became the centerpiece of bilateral exchanges this year. <...>
🇷🇺🇨🇳 The bond of comprehensive partnership and strategic cooperation between Russia and China has grown unprecedentedly strong thanks to the personal efforts of both heads of state. The Beijing summit sealed the two countries’ firm commitment to further deepen and expand it. This commitment was documented in the two leaders’ joint final statement.
This year, Russia and China celebrate 75 years of diplomatic relations. We mark this significant anniversary with achieving a new quality of relations – today, Russia and China view each other as priority partners and invariably adhere to the principles of mutually respectful, equal and trustful cooperation. We support each other with regard to key issues affecting the respective fundamental interests.
<...>
Strategic coordination in the international arena remains a key component of the Russian-Chinese partnership amid the growing international tensions. Our foreign policy tandem, held together by a broad commonality of interests as well as coinciding or similar approaches to key issues on the present-day agenda, plays a major stabilising role in global affairs.
☝️ The two countries are strengthening cooperation on multilateral platforms, primarily the Unite Nations and the UN Security Council, as well as #BRICS, #SCO, #G20, and #APEC.
<...>
The Russian-Chinese strategic tandem is gaining status, and this opens up new horizons for us in terms of stronger sovereignty, economic growth, and prosperity of both countries.
Read in full