Ранее я уже упоминал о другой фишке из ˍˍ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
🚗✨ Exciting news for luxury SUV enthusiasts! The new Range Rover Sport has been stunningly upgraded by Mansory!
🔧 The front bumper features a sleek splitter with stylish end caps and custom air vent overlays. The body kit includes new side skirts and a diffuser that perfectly complements the bespoke exhaust tips.
🔥 The Range Rover Sport SV boasts an alternative hood, unique inserts around the grille, and exclusive wheels available in 23 or 24 inches!
💰 While the price for these upgrades hasn't been disclosed, the demo model is already up for sale!
#RangeRoverSport#Mansory#LuxurySUV#CarEnthusiast#CustomCars#AutoDesign#LuxuryLifestyle#Auto
🌟 Introducing the Rolls-Royce Spectre with Spofec Customizations! 🚗✨
The German tuning experts at Spofec have taken the iconic Rolls-Royce Spectre to a whole new level! 🔥
🖤 New Features:
- Sleek Front Splitter with stylish daytime running lights 💡
- Side Skirts for a more aggressive profile 🏎️
- Rear Spoiler & Diffuser for enhanced aerodynamics 🌪️
- All components finished in a stunning black without chrome accents 🖤
📏 Performance Enhancements:
- Lowered suspension by 35mm for that perfect stance ⬇️
- Massive 24-inch Vossen SP3 wheels for an unforgettable look! 🛞
#RollsRoyce#Spectre#Spofec#LuxuryTuning#CarEnthusiast#CustomCars#VossenWheels#Auto
🚗✨Brabus Transforms Mercedes-AMG SL into a 1000-HP Shooting Brake!🔥
The new body and aerodynamic features are crafted entirely from carbon fiber. The turbocharged V8 has been enlarged from 4.0 to 4.5 liters, and now, combined with an electric motor on the rear axle, the powertrain delivers a staggering 1000 HP and 1620 Nm of torque! 💪⚡
These bespoke three-door beauties will be built to order, tailored to individual specifications. Pricing is not publicly disclosed. 💎
#Brabus#MercedesAMG#ShootingBrake#1000HP#LuxuryCars#CarEnthusiasts#CustomCars#AutomotiveExcellence#CarbonFiber#Auto
🚗💨Introducing the Doughboy: A Mind-Blowing Restomod with 2838 HP!💥
At the SEMA Show, we unveiled a beast that redefines power and performance! 🔥 This incredible V8 engine boasts a staggering 8.8 liters of displacement and is equipped with dual turbochargers, pushing the limits of automotive engineering. 💪✨
🔧 With the engine strategically shifted 40 cm back towards the center of the wheelbase, every detail has been meticulously crafted from scratch, including the intake, exhaust, and cooling systems. 🛠️
💎 Custom parts were expertly created using CNC machining and 3D printing technology, showcasing innovation at its finest.
Get ready to experience the future of restomods! 🚀
#Doughboy#SEMA2023#Restomod#V8Power#Turbocharged#CarEnthusiast#AutomotiveInnovation#CustomCars#CNC#Auto