Ранее я уже упоминал о другой фишке из ˍˍ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
🔥What makes Go! Smartchain unique from other platforms?
The Utilities are made specifically for your enjooooyment.
The name itself is exceptional.
See for yourself what the hype is about 👇
🔗https://medium.com/@%E2%80%8BGoRWAChain/go-ton-app-seeks-to-engage-100k-monthly-active-users-heres-how-you-can-benefit-a544f9923545
Go! is a platform which aims to empower you through tokenized assets and social impact initiatives
It's not just about crypto; it's about using blockchain to transform healthcare, education, and so much more.
The aim is to make a real impact on every person including you
#gosmartchainAI#Unique
#Impact#Tokenization#Blockchain
-------------------------
Join: 🐣X✉️Chat✉️News🤖Discord
Play: 🕹️TON App💻Web App
Info: 🖥Newsletter🌐Website🌐Blog
As Ai meets Web3 with the Go! Smartchain Ai, you get yourself a new and exciting experience.
Feel the Speed as you go through our Web App: https://chat.goplatform.io
Our Sweet consensus model Ensures you are safe, secure and you have a great time earning our token $GoXP
Ready for a Ride?
Get started at: https://chat.goplatform.io
#gosmartchainAI#GoWebapp
#Tokenization#Blockchain
#Getstarted
Join: 🐣X✉️Chat✉️News🤖Discord
Play: 🕹️TON App💻Web App
Info: 🖥Newsletter🌐Website🌐Blog
⚡️Never miss an opportunity to stay ahead of the Curve with Go!
🔗 Official Telegram
https://t.me/gorwachain
🔗 Official Discord
https://discord.gg/gorwachain
Go! Smartchain AI is a hub of innovations and always has juicy opportunities in store for you
What better way to harness these opportunities than joining the official platforms👇
Don't enjoy this privilege alone. Share the links to your friends to join in too. The more, the merrier 💥
#gosmartchainAI#Followup#Stayupdated#Discord#telegram
Join: 🐣X✉️Chat✉️News🤖Discord
Play: 🕹️TON App💻Web App
Info: 🖥Newsletter🌐Website🌐Blog