TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #397 · 12 ное.

Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs

Резултати

Пронајдени 4 слични објави

Пребарај: #withdrawals

当前筛选 #withdrawals清除筛选
SpotOnChain | Announcement

@spotonchain · Post #165 · 13.04.2023 г., 10:38

🔥🔥#Ethereum's Shanghai upgrade was completed 12 hours ago, let's review some stats: ➡️ Total $ETH staking is dropped from the peak of 18.163M to 17.476M ($34B) ➡️ Total withdrawn amount is about 124K $ETH (while the 24-hour deposit is 26.5K $ETH, so the net deposit is -97K $ETH ~ $192M) ➡️ Top withdrawer is LDO with 70,809 $ETH. But LDO won't allow users to withdraw until May, so most of the withdrawn $ETH is not liquidated. ➡️ $ETH price increases by 6% to $1,982, but with that price, 70% of stakers are still in loss (in USD terms) 🔗Link to current withdrawn status: https://etherscan.io/txsBeaconWithdrawal 🔗 Link to LIDO wallet: https://etherscan.io/address/0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f#withdrawals

Venture Village Wall 🦄

@venturevillagewall · Post #4353 · 10.03.2025 г., 13:00

Investors Withdraw $876M From Crypto Funds $876 million withdrawn from crypto funds last week. This marks the fourth consecutive week of outflows, despite new announcements in the U.S. #Crypto#Investments#US#Finance#Funds#Market#Trends#Trading#Withdrawals#Blockchain#Fintech#Economy#News#Updates#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #3862 · 13.01.2025 г., 07:00

FTX Client Claims Total $1.2 Billion FTX clients with claims under $50,000 total $1.2 billion, says creditor group representative Sunil Kavoury. Claims filing extended until January 20, with payments likely in February. Kraken initiates emails to clients for bankrupt FTX withdrawals, with payments under $50,000 expected within 60 days. BitGo might follow soon. #FTX#Kraken#Bankruptcy#Crypto#Payments#Finance#Investments#Claim#BitGo#Withdrawals#AI

Venture Village Wall 🦄

@venturevillagewall · Post #4214 · 22.02.2025 г., 04:00

Bybit Under High Withdrawal Pressure MEXC transferred 12,652 stETH ($33.75M) to Bybit's cold wallet. Bybit expected 64,452 ETH ($170M) in loan support from Bitget. An additional transfer of 11,800 ETH ($31M) occurred from Binance. Following a recent hack, Bybit recorded peak withdrawal levels, surpassing 350,000 requests; 99.994% have been processed. Links: Porter Stansberry, Ben Zhou #Bybit#MEXC#stETH#ETH#Crypto#Binance#Bitget#Bitcoin#Withdrawals#Whale#Finance#Hack#Blockchain#Investments#Market#Institutional#Debt#Liquidity#Trading#Assets#VC