Ранее я уже упоминал о другой фишке из ˍˍ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
📣Tonhub 2.3.4 Update Introduces DEX Integration
Tonhub 2.3.4 is now available, featuring integration with #DEXDedust.io, allowing users to buy, sell, or exchange #TON blockchain tokens directly within the wallet without additional fees. #DeDust#Tonhub
⚡️Boost | 🌐Twitter
💳 Tonhub non-custodial wallet launched a Visa debit card
Tonhub has launched a Visa debit card, allowing users to make payments directly from their $TON or $USDT balances. Available for European ID holders, the card offers minimal fees (1.5% per transaction) and supports global payments, including SEPA, SWIFT, Apple Pay, and Google Pay.
Tonhub plans to expand access to CIS, Latin America, and the Middle East by 2025 and integrate with wallets like TrustWallet. With accounts managed via smart contracts on the TON blockchain, users retain full control over their funds.
Learn more at Tonhub’s website.
#TON#SWIFT#ApplePay#Web3#GooglePay#Tonhub#USDT