Ранее я уже упоминал о другой фишке из ˍˍfutureˍˍ , это оператор деления.
from __future__ import division
Суть проста. Раньше сложность типа данных результата поределялась типом самого сложного операнда.
Например:
int/int => int
int/float => float
В первом случае оба операнда int, значит и результат будет int. Во втором float более сложный тип, поэтому результат будет float.
Если нам требуется получить дробное значение при делении двух int то приходилось форсированно один из операндов конверировать в float.
12/float(5) => float
Но с новой "философией" это не требуется. В Python3 "floor division" заменили на "true division" а старый способ теперь работает через оператор "//".
>>> 3/2
1.5
>>> 3//2
1
То есть теперь деление int на int даёт float если результат не целое число.
В классах теперь доступны методы __floordiv__() и __truediv__() для определения поведения с этими операторами.
Данный переход описан в PEP238.
#pep#2to3#basic
🚘Introducing the all-new Honda Ye S7 electric crossover! 🌿
🔋 Two-motor powertrain: 476 hp total power. Front wheels driven by a 204-hp electric motor, while the rear wheels by a 272-hp motor.
🏞️ Built on the e:N Architecture W platform with independent suspension, this 4.7-meter crossover promises a smooth ride.
🔌 Co-developed with Dongfeng, the Ye S7 is set to redefine the electric SUV experience.⚡️
#HondaYeS7#ElectricCrossover#Innovation#Auto
🌟🚗 Introducing the Genesis GV90! 🚗🌟
Get ready for the flagship electric crossover from Genesis, set to debut this October! 🎉✨ Built on the innovative eM platform, an evolution of the E-GMP architecture, the GV90 promises an impressive 113 kWh battery that offers a remarkable range of up to 800 km!🔋🌍
With its luxurious design and advanced features, the GV90 will compete with premium full-size SUVs like the Range Rover. 🏞️👑🚀
#GenesisGV90#ElectricCrossover#LuxurySUV#eMPlatform#Auto🌐🔋✨
🚘✨Introducing the Skoda Elroq Electric Crossover!✨🚘
The new Skoda Elroq is slightly larger than the Karoq, measuring 4488x1884x1625 mm with a wheelbase of 2765 mm. With a ground clearance of 186 mm, it’s ready for any adventure! 🌍💪
⚡️Performance Features:
- Available with electric motors producing 170, 204, or 286 hp.
- The top all-wheel-drive version boasts an impressive 299 hp! 🚀
- Range: From 375 to 560 km on a single charge! 🔋🌿
✅Simply Clever Innovations:
- Tire tread depth gauge integrated into the ice scraper! ❄️
- Elastic net under the luggage shelf for convenient charging cable storage! 📦🔌
ℹ️ The petrol Karoq starts at €33,100 in Germany, while the Elroq will be just €760 more! 💰🇩🇪
#SkodaElroq#ElectricCrossover#SimplyClever#SustainableDriving#CarLaunch#Auto#Innovation#Skoda