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

Резултати

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

Пребарај: #rose

当前筛选 #rose清除筛选
Coin Sonar

@CoinSonar · Post #244116 · 18.04.2026 г., 10:13

#ROSE | Volume spike (USDT PAIR) 12 times the average volume 134.03K USDT traded in 15 min └Buying vol: 92.71K USDT 🟢 Boost score: 6/10 24h Vol: 1.00M USDT (Binance) Price: 0.01165 (-3.4% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243288 · 16.04.2026 г., 19:20

#ROSE | Volume spike (USDT PAIR) 12 times the average volume 128.32K USDT traded in 15 min └Selling vol: 72.82K USDT 🔴 Boost score: 1/10 24h Vol: 1.00M USDT (Binance) Price: 0.01194 (-3.4% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #27946 · 20.09.2024 г., 15:39

#ROSE/USDT analysis : #ROSE is in an uptrend, forming higher highs and higher lows above the 200ema. The price is expected to sustain its bullish momentum and test new highs. Wait for a price retracement over the support zone for a long entry. TF : 2h Entry : $0.0606 Target : $0.0696 SL : $0.0561

Hashtags

American Crypto©

@americancryptotrading · Post #27315 · 18.07.2025 г., 08:02

🇺🇸#ROSE/USDT is breaking the descendingresistance on the daily chart🧐 Looks bullish✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27067 · 29.11.2024 г., 19:31

🇺🇸#ROSE/USDT completes descendingchannel breakout on the 2D timeframe💁‍♂️ Bullish✈️ American Crypto©

Hashtags

Coinlegs Cryptocurrency Signals

@coinlegs · Post #10038 · 01.03.2024 г., 15:31

#ROSE +%33 in just 5 days 🤑🤑 Legs Trading Hub VIP members are just enjoying their profits 🍹 We are crafting our signals by the power of CoinLegs algorithms. Why don't you chime in and say hello? ⤵️ https://discord.com/invite/8RKtAA9cxZ

Hashtags

123•••10•••1314
ПретходнаСтраница 1 од 14Следна