Вторая по частоте 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
💨 Nothing on the road will scare you after this
🇸🇪 In Sweden, driving schools teach students how to handle a car in all kinds of tricky conditions.
🚗 And yes — passing a skid-control test is mandatory before they can even get their license.
#driving@Car_News
🚗🇺🇸1 IN 3 US PARENTS FEAR TEEN DRIVERS WILL CAUSE DEADLY CRASH
🔹 University of Michigan poll: 33% worry their young driver could cause accident — but 96% think their kid drives "average or better" 🤔📊
🔹 Half (51%) witnessed unsafe behavior: 44% saw aggressive driving, 25% caught texting while driving, 17% saw impaired/sleepy driving 😱🚨
🔹 Only 24% imposed consequences — most just take keys (6%), refuse car (8%), or threaten insurance cuts (6%) 🔑💳
🔹 Parents who saw road rage LESS likely to rate teen as bad driver — massive blind spot putting lives at risk 🙈💀
American teens NOT ready for the road. Where are the parents? 😬🛣️
#USNews#teensafety#driving
@america
J-j家j谱p- 家谱 The Family Tree (2011)
直达链接:https://pan.quark.cn/s/32c4d8126f28
#家谱#The Family Tree #Driving Lessons
链接:https://link3.cc/sf_com
#电影#喜剧#美国#10年代
🔥🏁Koenigsegg Regera Breaks Rimac Nevera's Record in 0-400-0 Challenge 🏁🔥
🏆 The music didn't play for long: Rimac Nevera's record in the 0-400-0 km/h acceleration-braking challenge lasted only a month. The Croatian hypercar surpassed the previous record holder, Koenigsegg Regera, clocking in at 29.94 seconds.
🇸🇪 The Swedish brand shrugged and sent the Regera back onto the track. Guess what? 28.81 seconds. How do you like that, Mate Rimac?
🥇 The margin of victory was 1.13 seconds, which in such a discipline, it must be said, is quite impressive. Surely, Rimac will have to respond. Competing is possible, but it will definitely require some effort.
🏎️Interestingly enough, the Regera has already been discontinued, with the last unit delivered to its owner in 2022. So why set a record with a car that is no longer in production? Koenigsegg answers bluntly: "Because it can!" The Regera remains superior to any newcomer. And it has proven it once again.
💥To outperform a significant rival - an electric car that has just set 23 records - is both impressive and beautiful. 💥
#Koenigsegg#Regera#driving#car