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

Резултати

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

Пребарај: #stx

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

@CoinSonar · Post #244139 · 18.04.2026 г., 11:11

#STX | Volume spike (USDT PAIR) 29 times the average volume 109.22K USDT traded in 5 min └Selling vol: 76.58K USDT 🔴 Boost score: 1/10 24h Vol: 1.08M USDT (Binance) Price: 0.2332 (-2.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243737 · 17.04.2026 г., 15:21

#STX | Volume spike (USDT PAIR) 219 times the average volume 164.27K USDT traded in 1 min └Buying vol: 115.95K USDT 🟢 Boost score: 6/10 24h Vol: 1.08M USDT (Binance) Price: 0.2469 (-2.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243627 · 17.04.2026 г., 12:00

#STX | Volume spike (USDT PAIR) 29 times the average volume 108.55K USDT traded in 5 min └Buying vol: 67.85K USDT 🟢 Boost score: 4/10 24h Vol: 1.08M USDT (Binance) Price: 0.2421 (-2.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243500 · 17.04.2026 г., 07:26

#STX | Volume spike (USDT PAIR) 11 times the average volume 129.25K USDT traded in 15 min └Buying vol: 80.72K USDT 🟢 Boost score: 4/10 24h Vol: 1.08M USDT (Binance) Price: 0.2412 (-2.7% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243302 · 16.04.2026 г., 20:02

#STX | Volume spike (USDT PAIR) 32 times the average volume 121.23K USDT traded in 5 min └Buying vol: 66.12K USDT 🟢 Boost score: 4/10 24h Vol: 1.08M USDT (Binance) Price: 0.2479 (-2.7% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28484 · 20.02.2025 г., 13:20

#STX/USDT Analysis : #STX has bounced back from a key support zone and is likely to move up towards the swing high levels. For a long entry, it's advisable to wait for a price retracement to get a better entry point. TF : 4H Entry : $0.910 Target : $1.010 SL : $0.842

Hashtags

Pro Analysis

@proanalysistrader · Post #28428 · 27.01.2025 г., 13:48

#STX/USDT analysis : #STX is currently in a downtrend, trading below the 200 EMA and consistently making new lows. The price has broken below the previous support zone and has formed a lower low. It is recommended to wait for a retest of this support zone for a potential short entry, as further price declines are anticipated, targeting lower levels. TF : 4h Entry : $1.347 Target : $1.056 SL : $1.536

Hashtags

Pro Analysis

@proanalysistrader · Post #27864 · 22.08.2024 г., 05:37

#STX/USDT analysis : #STX has formed a rejection candle over the support zone and bounced off from there, expected to continue its bullish momentum to test previous highs. TF : 1W Entry : $1.609 Target : $2.792 SL : $1.045

Hashtags

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