Ранее я уже упоминал о другой фишке из ˍˍ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
🚨*ATTENTION*
*The British chapter of the Antifascist International* calls on the oppressed of the world to stand firmly with Venezuelan 🇻🇪 sovereignty and to denounce *UK complicity* in the imperialist war against *Venezuela*.
All out! Join us!
🗓 10 January ⏰ 1:00pm
🏢 Downing Street
🥁 Bring noise, flags, banners!!
#HandsOffVenezuela
https://antifascistinternational.uk/solidarity-with-the-people-of-the-bolivarian-republic-of-venezuela-and-president-nicolas-maduro-moros/
Erklärung der DKP zu den US-Angriffen gegen Venezuela!
Jetzt lesen unter unsere-zeit.de/haende-weg-von-venezuela-3-4810421/
#handsoffvenezuela#venezuela#usa
Responding to a call from the International People's Assembly, ALBA Movimientos, The Simon Bolivar Institute and The Assembly of Caribbean Peoples, activists worldwide rallied against US intervention in Venezuela and supported its recent presidential election.
From Kinshasa to Seoul, Rome to Luanda, and beyond, demonstrations defended Venezuelan democracy and sovereignty. In cities like Oslo, Vigo, and Pretoria, participants voiced solidarity with the Venezuelan people and the Bolivarian Government and condemned fascism and imperialist actions.
Click here to view the full gallery 👉🏼https://shorturl.at/YV7b0
#handsoffVenezuela#Venezuela#solidarity#internationalpeoplesassembly
🇺🇸🕊️El imperio no habla por su pueblo
⚡️Mientras Trump escala su agresión contra Venezuela, crece la resistencia interna en Estados Unidos. Organizaciones pacifistas protestaron frente al Congreso para denunciar la larga historia de intervenciones ilegales impulsadas desde la Casa Blanca.
📄 Respaldados por más de 15.000firmas, los activistas exigieron apoyo a la Resolución Constitucional 68, que ordena retirar a las Fuerzas Armadas de EE.UU. de Venezuela por carecer de aval legislativo.
👉 Incluso dentro de EE.UU., la guerra pierde legitimidad.
#NoALaGuerra
#TrumpAgresor
#VenezuelaResiste
#PuebloDeEEUUContraLaGuerra
#NoMásIntervenciones
#RespetoAlDerechoInternacional
#AntiImperialismo
#PeaceNotWar
#HandsOffVenezuela