Вторая по частоте 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
“When they attacked some village, they called all the people to one place. ‘Everyone must follow us and our religion. If not, we must shoot you,’” says Khuseini from Nigeria about Boko Haram terrorists.
This criminal group is responsible for killing thousands of people. Khuseini and his family fled their hometown when Boko Haram arrived. Now he lives in the Dar es Salaam refugee camp and teaches Arabic to kids at the local school. Khuseini says the kids are deeply traumatised by the terrorists’ brutality. They remember how Boko Haram attacked their town, killing their friends. There are machine guns, blood, and killings even in kids’ drawings.
Today is Children’s Day in Nigeria. Watch the clip to see how kids – Boko Haram’s victims - live in the refugee camp and try to get back to everyday life. Then, find out more in our documentary Hot Spot Chad.
#crime
Follow: https://t.me/rtdocumentary
‘He’s not resisting arrest; he’s on the ground. You’ve him in handcuffs. Why is there a need to hit him in the back with a rifle?’ – asks a desperate mother whose child died due to police brutality. Quincy and his girlfriend argued, he left the house, leaving her angry. She called the police and told them he had a rifle. That fatal lie cost Quincy his life. Five police officers didn’t even intend to find out the truth but tackled and beat the young man to death.
Cases like this are common in the USA. Hundreds of people die every year at the hands of law enforcement officers. Watch the clip to see some cases. Do you think it’s possible to change the situation? See the documentary Once Upon A Crime to learn what people do to stop police brutality.
#crime
Follow: https://t.me/rtdocumentary
🎬 Adolescence
Gênero: #Crime, #Drama
⭐️ IMDb: 8.1
⏳ Duração: 15 Episódios
📝 Sinopse:
Quando um garoto de 13 anos é acusado do assassinato de um colega de classe, sua família, o terapeuta e o detetive responsável ficam perguntando o que realmente aconteceu.
Fonte: IMDb
🔵Inscreva-se em @Assistir
*Patrocinado: Anime Bot
🍿 'The Penguin': The Most Anticipated Spin-off of 'The Batman' 🎬
📆Premiere: September 19, 2024
🎭Genre: #Crime · #Drama
Colin Farrell dives into the role of Oz Cobb, aka The Penguin, in this series that promises to expand the universe of Matt Reeves' 'The Batman.' With 3.5 hours of daily makeup, Farrell transforms into Gotham's crime boss. The trailer, unveiled at Comic-Con, left everyone in awe. 🎥
The interesting part is how Reeves initially planned a series for DC, and HBO finally made it happen. Cristin Milioti and Rhenzy Feliz join Farrell in an impressive cast. And watch out! The Penguin will return in 'The Batman II' in 2026. 🦇✨
🍿The Penguin: Colin Farrell Returns to Gotham
📆Release: Fall 2024
🎭Genre: #Crime · #Drama
The new trailer for 'The Penguin' brings Colin Farrell back as Gotham's infamous gangster, Oswald Cobblepot. This spin-off from Matt Reeves' 'The Batman' follows Cobblepot's rise to power after the death of Carmine Falcone. 🚦🔫
What's really fascinating is how Farrell's makeup has evolved, giving him an even more menacing look true to the iconic DC villain. Plus, the brewing tension with Sofia Falcone, played by Cristin Milioti, promises electrifying drama. Don't miss this thriller, which is already shaping up to be a hit. 🌆🔥
> 𝘴𝘦𝘳𝘪𝘦𝘴 · 🚀𝘣𝘰𝘰𝘴𝘵