Вторая по частоте 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
🌟Thinking of applying for the IRAS scholarship?
Get insider tips from our current scholars to help with your application. ✍️ Don’t miss this opportunity to contribute meaningfully to Singapore’s economic and social growth. Apply to be an IRAS scholar at go.gov.sg/scholarapply by 31 March 2026.
#IRASscholarships#scholarships
Where tax builds tomorrow. 🇸🇬
Our scholars Nathaniel, Jing Rong, and Yern-Wei share about their journey in IRAS and how their work drives Singapore’s economic growth and inclusive society. Join us and discover diverse, purpose-driven careers that foster dynamic learning and collaborative innovation!
Watch the full video here: https://youtu.be/sHnS6XFP-HA?si=m-uuab47jrjnr47H
✍️ Apply to be an IRAS scholar today at go.gov.sg/scholarapply.
#IRASscholarships#scholarships
Where every expertise matters. 💼
At IRAS, we bring together different disciplines and unique specialists to work on projects that drives Singapore’s economic growth. IRAS scholarships are open to students from diverse areas of study.
Watch the full video here: https://youtu.be/sHnS6XFP-HA?si=m-uuab47jrjnr47H
Apply to be an IRAS scholar today at go.gov.sg/scholarapply.
#IRASscholarships#scholarships
Where tax builds tomorrow.💡
With pre-filled forms containing income details and tax reliefs, filing taxes is done in a matter of minutes. But what goes on behind-the-scenes to create this smooth taxpaying experience? Meet IRAS Director Leong Shi Wei, who leads multidisciplinary teams that oversee data policy, governance, and digital partnerships - making paying taxes a seamless and automated experience. Learn more about his work at IRAS here: https://go.gov.sg/iras-designing-the-tax-experience
Ready to collaborate with diverse teams on projects of national importance? 🇸🇬Apply to be an IRAS scholar today at go.gov.sg/scholarapply. Applications close on 31 Mar 2026.
#IRASscholarships#scholarships
Where every expertise matters.🧪
At IRAS, we bring together diverse and unique disciplines and specialists to drive projects that shape Singapore’s future. Meet Charmaine Tan, an IRAS scholar pursuing her Bachelor of Science in Life Sciences and Minor in Forensic Science, as she shares how her academic passion translates into meaningful impact.
Ready to put your expertise towards nation-building? 🌟 Apply to be an IRAS scholar today at go.gov.sg/scholarapply.
#IRASscholarships#scholarships
Where growth knows no limits. 🌱
What does it mean to be an IRAS scholar? Meet Shaine Goh (Software Engineer, Infocomm Division) whose journey with the IRAS Merit Undergraduate Scholarship turned her potential into real-world impact. 💼 From computing skills to transforming tax services, Shaine shows how innovation can reshape the taxpayer experience. Read her story: go.gov.sg/iras-shaine-goh
At IRAS, we invest in your personal growth so you can maximise your full potential. Ready to grow without limits? ✨ Apply to be an IRAS scholar today at go.gov.sg/scholarapply.
#scholarships#IRASscholarships
Where tax builds tomorrow.
IRAS scholarships are your gateway to a meaningful career that propels Singapore’s economic growth forward. Take your first step with us and unlock endless possibilities.
Ready to shape tomorrow? Learn more about life at IRAS at go.gov.sg/lifeatiras and visit go.gov.sg/scholarapply to apply to be an IRAS scholar via BrightSparks today.
#scholarships#IRASscholarships
🌐 As a Tax Director in IRAS’ Corporate Tax Division, IRAS scholar Joanne Tan refines tax laws and shapes policies that strengthen Singapore’s economic future, while leading a team of officers to discover the dynamic side of tax work. Learn more about her journey at IRAS here.
Apply for IRAS scholarships today at go.gov.sg/scholarapply
#lifeatIRAS#IRASscholarships#scholarships
Have questions about IRAS Scholarships? We’re here to answer them. 💬
Our scholarship application is now open, so don’t miss out! Apply today at go.gov.sg/scholarapply.
For more details, feel free to reach out to us at [email protected].
#IRASscholarships#scholarship#lifeatiras
📢 Calling all A-level/IB graduates and university students from all disciplines!
Catch a glimpse of life as an IRAS intern – follow our scholar Gerald Wong through his #dayinthelife.
Ready to make a difference? Join our future-ready #IRASFam and do work that matters in a collaborative, empowering environment. 🚀 Apply for IRAS scholarships at go.gov.sg/scholarapply or internships at www.careers.gov.sg today.
#lifeatIRAS#IRASscholarships