Ранее я уже упоминал о другой фишке из ˍˍ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 Pininfarina B95 Gotham!🦇✨
Inspired by the legendary hero Bruce Wayne, this hypercar is designed for those who dare to push the limits! 💪🔥
Featuring the iconic Wayne Enterprises logos, the B95 Gotham showcases a stunning design that embodies the spirit of Gotham City. 🏙️🖤 On the driver's door, you’ll find the powerful quote: "All men have limits... I ignore mine." — a true testament to the Dark Knight’s relentless pursuit of excellence. 🗣️💬
The car's displays come alive with custom graphics, and even the virtual assistant speaks in the voice of Alfred Pennyworth, bringing a touch of elegance and sophistication to your driving experience. 🎩🤖
And this isn’t just a show car! A limited number of these masterpieces will be produced by order. Don’t miss your chance to own a piece of superhero history! 🌌🚀
#Pininfarina#B95Gotham#BruceWayne#Hypercar#Auto🖤🔧
🚗✨ Introducing the Unique Pininfarina Battista Targamerica! 🌟
Pininfarina has unveiled a stunning roadster, the Battista Targamerica, crafted for a special client who already owns the Battista coupe. This exclusive model features a sleek convertible design with a refined rear end. 🌈🛠️
One of the standout elements of the interior is a bespoke cigar holder and humidor, specially made for this one-of-a-kind vehicle. The custom aluminum and glass case can hold up to three cigars, adding a touch of luxury to every drive. 💨💼💨
Under the hood, the Battista Targamerica boasts the same incredible four-motor powertrain as the Rimac Nevera, delivering a jaw-dropping 1900 horsepower!⚡️💥 It accelerates from 0 to 60 mph in under 2 seconds!🚀🔥
This masterpiece is not just a car; it's an experience!
#Pininfarina#BattistaTargamerica#LuxuryCars#Roadster#CustomDesign#CigarLovers#ElectricSupercar#Performance#Auto🚗💖