Ранее я уже упоминал о другой фишке из ˍˍ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
Our latest community spotlight is here! 🛠️🚀 This week we meet Almaz: Chemical engineering student, all-round creative thinker, and #buidler of WeaveWatcher and Arweave.Design 📢😎http://bit.ly/MeetAlmaz
Introducing the Buidl Contributor role 🤍
This role is for community members who actively help Buidlpad grow through community participation, support, boosts and engagement.
Contribute consistently to unlock future role-based rewards!
Join the Buidlpad Discord Community → http://discord.gg/buidlpad
▫️What is the Buidl Contributor Role?
Buidl Contributor is the next role in our series of Community Role Launches
This role recognizes users who actively support the Buidlpad community by contributing time, effort & presence.
It focuses on community participation & engagement, not capital.
▫️How to Get the Buidl Contributor Role?
🔹 Join the Buidlpad Discord: http://discord.gg/buidlpad
🔹 Verify yourself in #buidler-role (skip if you've already done this)
🔹 Choose the contributor role in #role-verify
🔹 Engage the Server Booster Role by Boosting the Server
🔹 Start contributing!
The alpha is to stay active in community channels and participate consistently in community activities
Roles are reviewed and rewards are calculated on consistent contributions.
How to verify and receive your roles
🔹 Log in at http://buidlpad.com
🔹 Link your Discord under your Profile
🔹 Join the Buidlpad Discord: http://discord.gg/buidlpad
🔹 Verify yourself in #buidler-verify
🔹 Select your region in #select-region
That’s it. Your verification is complete 💙
Or follow this tutorial ⬇️ Or DM : @gBuidl