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

Резултати

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

Пребарај: #rad

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

@CoinSonar · Post #244170 · 18.04.2026 г., 12:20

#RAD | Volume spike (USDT PAIR) 9 times the average volume 252.67K USDT traded in 15 min └Buying vol: 134.97K USDT 🟢 Boost score: 2/10 24h Vol: 2.49M USDT (Binance) Price: 0.255 (-0.9% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243807 · 17.04.2026 г., 18:22

#RAD | Volume spike (USDT PAIR) 9 times the average volume 252.45K USDT traded in 15 min └Buying vol: 172.27K USDT 🟢 Boost score: 3/10 24h Vol: 2.49M USDT (Binance) Price: 0.254 (-0.9% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243568 · 17.04.2026 г., 09:24

#RAD | Volume spike (USDT PAIR) 58 times the average volume 101.04K USDT traded in 1 min └Buying vol: 82.49K USDT 🟢 Boost score: 8/10 24h Vol: 2.49M USDT (Binance) Price: 0.255 (-0.9% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243465 · 17.04.2026 г., 05:49

#RAD | Volume spike (USDT PAIR) 9 times the average volume 255.13K USDT traded in 15 min └Buying vol: 149.81K USDT 🟢 Boost score: 5/10 24h Vol: 2.49M USDT (Binance) Price: 0.237 (-0.9% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28503 · 27.02.2025 г., 13:04

#RAD/USDT analysis : #RAD is currently experiencing a bearish trend, trading below the 200 EMA. The price is forming lower lows (LLs) and lower highs (LHs). At present, it is testing the resistance zone along with the 200 EMA. A reversal is anticipated from this level, allowing the price to resume its bearish momentum and potentially test lower levels. TF : 1H Entry : $0.840 Target : $0.779 SL : $0.875

Hashtags

Pro Analysis

@proanalysistrader · Post #28097 · 30.10.2024 г., 13:44

#RAD/USDT analysis : #RAD has broken out and retested the previous support levels. It is expected to reject from the current level and test lower levels. TF : 1h Entry : $1.209 Target : $1.127 SL : $1.268

Hashtags

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