Вторая по частоте 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
Thiago Alcántara ha decidido retirarse del fútbol profesional.
El exjugador de Barça, Bayern, Liverpool y España ha tomado su decisión.
La pasión y el amor de Thiago por el juego continúan mientras está listo para un nuevo capítulo en el fútbol después de algunos meses de planificación.
📱: Fabrizio Romano
@Fut_Planet⚜️#Thiago⚽️
Lara, speaking from Brazil, has had no contact with her husband, Thiago Ávila, since he was abducted and detained illegally by Israeli forces from the 'Madleen'. Since then, Thiago has been placed in solitary confinement, denied communication with his family.
According to Lara, Israeli authorities threatened Thiago with the psychological torment of isolation without light or ventilation. Despite this, Thiago remains on hunger strike, holding firm to his belief in justice for Palestinians and the right of every child to food, safety, and freedom.
From his prison cell, he wrote a letter to his 1-year-old daughter. Lara generously shares that with us today.
This is a call not just for Thiago’s release—but for the world to pay attention to Gaza, to Palestine, and to all people who are exploited, forced to live under occupation.
#FreedomFlotilla#Madleen#Thiago#IOF#WeWillSail#BreakIsraelsSiege#EndTheBlockade
"Families of Gaza are not less important than my family. It’s by mere chance that we are not one of those families that are in Gaza right now."
Thiago Ávila, father and activist aboard 'Handala', will sail towards Gaza with an urgent mission: to break the illegal siege and stand with the children of Gaza. 'Handala' is a small boat, but it carries the weight of a global uprising for justice. As catastrophic famine unfolds across Gaza, evidence of heinous sexual and physical violence by the IOF continues to emerge, and the Israeli and U.S.-backed genocide persists with impunity, people power is more integral than ever—it’s up to us to shape a new society.
The world must not turn its eyes away. Keep your eyes on 'Handala'. Share our mission, amplify Palestinian voices, and do everything you can to stand for Gaza. The flood of change is coming—be part of it. #FreedomFlotilla#Handala#FreePalestine#Gaza#AllEyesOnDeck#FreeGaza#WeWillSail#Thiago#Brazil#HumanRights#Genocide#IOF