Ранее я уже упоминал о другой фишке из ˍˍ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
it looks like the $METAWIN tge is coming soon 👀
so if you’ve been in my channel for awhile you know that this is one of my higher conviction plays
every single person who makes a deposit on metawin.com/tg/ is going to get an airdrop when they launch
make sure you do before it’s too late!
#METAWIN#Ethererum#ETH#TSLA#TESLACALLS
⌛️Still confused about the “pending” transaction status when transferring #BTC?
#TokenPocket provides the #Bitcoin Acceleration Service for all of you!
✅Time-saving
✅Simplicity
✅Multiple payment methods
💰Now we support $USDT payment method.
You can use $USDT to pay for transaction acceleration on the following platforms ethereum , BNBCHAIN , and trondao.
Tutorial Guide 👇
https://help.tpwallet.io/en/wallet-faq-en/btc-wallet/acceleration
#USDT#Ethererum#BNBChain#TRON
【Details】https://twitter.com/TokenPocket_TP/status/1722600788286202003
【Powered By】Crypto Box
⌛️Fed up with “pending” transaction status when Minting and Trading #Ordinals?
🚀Speed up your #BTC transaction with #TokenPocket's transaction acceleration service!
👉https://tokenpocket.pro
✅Time-saving
✅Simplicity
✅Multiple payment methods
💰Now we support $USDT payment method.
You can use $USDT to pay for transaction acceleration on the following platforms ethereum, BNBCHAIN, and trondao.
Say goodbye to transaction delays and hello to seamless trading!
Don't let FOMO slow you down.
Tutorial Guide 👇
https://help.tpwallet.io/en/wallet-faq-en/btc-wallet/acceleration
#USDT#Ethererum#BNBChain#TRON#BRC20
【Details】https://twitter.com/TokenPocket_TP/status/1725134953154052137
【Powered By】Crypto Box