Ранее я уже упоминал о другой фишке из ˍˍ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
🌍 In China’s Loess Plateau, newly re-greened hills now support high-yield crops where dust once blew. Decades of restoration turned dry slopes into one of the world’s largest farming recoveries. ✨
#agriculture⚡#restoration⚡#land⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
Re-thinking “Land to the Tiller” Read more.
https://borkena.com/2025/12/03/land-to-the-tiller-re-thinking-ethiopias-land-to-the-tiller/#Ethiopia#politics#land#Landtothetiller
🌍 Desertification, the spread of deserts into once-fertile land, now threatens over a third of Earth’s land surface, endangering food security for millions worldwide. ✨
#desertification⚡#climate⚡#change⚡#land⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
S-s失s落l的d大d陆l- 失落的大陆 Land of the Lost (2009)
直达链接:https://pan.quark.cn/s/4bf2c474bd21
#失落的大陆#Land of the Lost
#失落之地#迷失侏罗纪
链接:https://link3.cc/sf_com
#电影#喜剧#美国#00年代