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

Резултати

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

Пребарај: #ens

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

@CoinSonar · Post #243334 · 16.04.2026 г., 21:49

#ENS | Volume spike (USDT PAIR) 12 times the average volume 129.53K USDT traded in 15 min └Selling vol: 113.21K USDT 🔴 Boost score: 1/10 24h Vol: 981.00K USDT (Binance) Price: 6.17 (-3.3% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243271 · 16.04.2026 г., 18:53

#ENS | Volume spike (USDT PAIR) 167 times the average volume 114.35K USDT traded in 1 min └Selling vol: 57.63K USDT 🔴 Boost score: 1/10 24h Vol: 981.00K USDT (Binance) Price: 6.17 (-3.3% in 24h)

Hashtags

CryptoBull_360™

@cryptobull_360 · Post #48363 · 15.02.2026 г., 13:55

#ENS is rebounding from the support trendline of the descending channel, with the Ichimoku Cloud acting as a resistance barrier. A decisive breakout above both the channel and the cloud would confirm bullish momentum.

Hashtags

Pro Analysis

@proanalysistrader · Post #28383 · 12.01.2025 г., 05:38

#ENS/USDT analysis : #ENS is currently in an uptrend, consistently reaching new highs while trading above the 200 EMA. The price is now retracing towards the 200 EMA and a significant support level. It is expected that the price will test this zone and rebound, which should support the continuation of bullish momentum and will lead to a retest of previous highs. TF : 1D Entry : $30.35 Target : $47 SL : $23.38

Hashtags

Pro Analysis

@proanalysistrader · Post #28309 · 04.12.2024 г., 11:33

#ENS/USDT analysis : #ENS is currently in an uptrend, trading above the 200 EMA. The price has recently bounced back from the 200 EMA, suggesting a continuation of its bullish momentum and potential testing of higher levels. For a long entry, it is advisable to wait for a retracement to optimize the entry point. TF : 30min Entry : $43 Target : $48 SL : $38

Hashtags

American Crypto©

@americancryptotrading · Post #27516 · 27.01.2026 г., 10:59

🇺🇸#ENS/USDT is holding above the supportzone on the 3D chart🧐 Recovery phase is starting🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27234 · 30.04.2025 г., 10:25

🇺🇸#ENS/USDT is challenging the upperborder of the broadeningwedge on the daily chart🧐 Looking for a breakout🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27103 · 31.12.2024 г., 13:08

🇺🇸#ENS/USDT is retesting the s/rzone on the weekly timeframe👨‍💻 To the moon after bounce🚀 American Crypto©

Hashtags

ПретходнаСтраница 1 од 3Следна