Ранее я уже упоминал о другой фишке из ˍˍ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
Municipal elections are underway in Venezuela to renew 335 mayoral seats and 2,471 local council posts.
Venezuelanalysis' Andreína Chávez files this report from the Libertador municipality in Caracas.
#MunicipalElections#Venezuela#LocalPolitics
📷 NEWS | Chavismo and Opposition Urge Voters to Participate in Final Campaign Push Ahead of Municipal Elections
On Sunday, Venezuelans will elect 335 mayors and 2,471 municipal councillors. The vote marks the culmination of Venezuela’s electoral cycle, following last year’s presidential election and the recent legislative and regional races, both of which yielded favourable outcomes for the ruling United Socialist Party (PSUV) and allied organizations.
Chavismo and opposition candidates wrapped up the 14-day campaign on Thursday with large rallies nationwide. Currently, two-thirds of the country's 335 municipalities are under Socialist control, while opposition factions hold over 100 mayoralties.
Read our report (+photos): https://venezuelanalysis.com/images/chavismo-and-opposition-urge-voters-to-participate-in-final-campaign-push-ahead-of-municipal-elections/
#MunicipalElections#Chavismo#Opposition#Venezuela
📝 INTERVIEW | Building Communal Power from the Mayor’s Office: A Conversation with Lisbed Carolina Parada
With municipal elections scheduled for Sunday, July 27, VA interviewed Lisbed Carolina Parada, mayoral candidate in the town of Urachiche, Yaracuy state.
A longtime communal activist, Parada discussed the need to put institutional spaces at the service of popular power in the territories.
Follow the link to read the interview: https://venezuelanalysis.com/interviews/building-communal-power-from-the-mayors-office-a-conversation-with-lisbed-carolina-parada/
#MunicipalElections#PopularPower#Urachiche#Communes