Ранее я уже упоминал о другой фишке из ˍˍ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
#Sentiment notes that the activity of #BTC discussion on social media has risen to a 4-month high, there is a serious panic among the crowd. Such depressive indicators in the moods usually preceded the rebounds.
⚡️ Sentiment notes a decrease in the number of wallets with a non-zero balance 🪙#BTC, which may mean that some participants will enter the cache before the US elections. The experts of #Sentiment consider this development of the situation to be #bullish for #BTC after the elections are held...
#Sentiment notes a sharp rise in bullish sentiment in #Solana
there are rumors that #Apple (#AAPL) is starting to use the Solana — Sentiment blockchain
🤣Ethereum Fear & Greed Index has dropped to 13, signaling Extreme Fear across the market.
市場情緒跌入 極度恐懼區間,代表短期資金風險偏好明顯下降,投資人情緒趨於保守。
#Crypto#以太坊#币圈#区块链
⚡️ 歷史上極度恐懼區域,往往出現在市場接近階段性底部時,但短線波動仍可能持續。
#Ethereum#Markets#Sentiment
———
👇⭐️👇
🤣留言分享觀點
🥲👇