Ранее я уже упоминал о другой фишке из ˍˍ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
Sen. Bernie Sanders (D-VT) got animated during an interview with CNN's Kaitlan Collins on Tuesday night over President Donald Trump's latest threat to withhold federal funding from New York City.
Sanders joined Collins to discuss the looming government shutdown. He expressed concern that the Trump administration could use the shutdown to continue advancing its authoritarian agenda, citing previous examples like firing workers that "they don't like" from the Veterans Administration and making significant cuts to Medicaid.
"I'll give you another example, as I'm sure you've heard of it," Sanders told Collins. "I think it was yesterday. Trump says, 'Well, if Mr. [Zohran] Mamdani becomes the mayor of New York City, then I'm going to cut funding from New York City.'"
#Trump#Sanders
👂More on Trump's Ear ⚠️
✊ As Senator Bernie Sanders and Representative Alexandria Ocasio-Cortez joined Zohran Mamdani on Sunday at Forest Hills Stadium, a bigger test for the left may still lie ahead. 🌆📣
#NY#Mamdani#Sanders
👂More on Trump's Ear
⚠️
🇺🇸 Spinto da giovani e ispanici, Bernie #Sanders ha stravinto i #caucus del #Nevada.
➡️ Tutti i risultati e l'analisi del voto:
https://www.youtrend.it/2020/02/24/come-bernie-sanders-ha-vinto-in-nevada/
#USA#Primarie#D
Secondo il WP, gli stretti collaboratori di Bernie #Sanders (#VPP|Sinistra) riferiscono che il Senatore sarebbe pronto a candidarsi alle primarie democratiche nel 2024, qualora il presidente in carica Joe #Biden rifiutasse di correre per la rielezione.
@UltimoraPolitics
#USA#Ucraina#Israele#Taiwan
Il #Senate ha approvato, con 67 voti favorevoli e 27 contrari, la chiusura dell’accordo per la fornitura di aiuti per un ammontare pari a 95 miliardi di dollari a Ucraina, Israele e Taiwan.
Anche 18 senatori repubblicani hanno votato a favore dell’accordo, mentre Bernie #Sanders (#D|Centro-sinistra) è stato l’unico dem ad opporsi alla fornitura di aiuti a tali nazioni.
@OsservatorioEsteri
Attualmente, Joe #Biden ha un vantaggio larghissimo in #Mississippi e #Missouri, un vantaggio ampio in #Michigan e un vantaggio molto ristretto in #NorthDakota.
Bernie #Sanders invece ha un vantaggio ristretto in #Idaho, #Washington e fra i #DemocratsAbroad