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

Резултати

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

Пребарај: #ata

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

@CoinSonar · Post #244055 · 18.04.2026 г., 07:57

#ATA | Volume spike (USDT PAIR) 509 times the average volume 208.43K USDT traded in 15 min └Buying vol: 120.23K USDT 🟢 Boost score: 1/10 24h Vol: 39.30K USDT (Binance) Price: 0.0119 (-3.0% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #244001 · 18.04.2026 г., 05:56

#ATA | Volume spike (USDT PAIR) 790 times the average volume 107.88K USDT traded in 5 min └Buying vol: 86.67K USDT 🟢 Boost score: 6/10 24h Vol: 39.30K USDT (Binance) Price: 0.0119 (-3.0% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #27972 · 29.09.2024 г., 12:39

#ATA/USDT analysis : #ATA is currently finding support above the 200-period exponential moving average (200 EMA) within the support zone. The price is anticipated to test this zone and maintain its bullish momentum to reach the previous swing high. TF : 4h Entry : $0.0900 Target : $0.0983 SL : $0.0850

Hashtags

American Crypto©

@americancryptotrading · Post #27544 · 24.02.2026 г., 09:49

🇺🇸#ATA/USDT is consolidating near the lowerborder of the descendingchannel formation on the weekly timeframe🔍 Market recovery is underway🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27077 · 08.12.2024 г., 17:57

🇺🇸#ATA/USDT is forming a descendingchannel on the weekly timeframe💁‍♂️ Send it if we do breakout🚀 American Crypto©

Hashtags

We want you

@we_want_youu · Post #4196 · 14.08.2024 г., 05:54

Currently, #ATAUSDT is compressed within a falling wedge pattern, a classic bullish reversal signal. Should #ATA fail to bounce back from the $0.0820-$0.0700 support, our eyes will be on the next critical level at $0.0580. Historically, this level has been a stronghold, and the probability of a rebound here is notably higher. But if $ATA breaks below these key support levels, the bears might take control, potentially leading to a bearish continuation.

Hashtags

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