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

Резултати

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

Пребарај: #wld

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

@CoinSonar · Post #243961 · 18.04.2026 г., 04:18

#WLD | Volume spike (USDT PAIR) 70 times the average volume 729.89K USDT traded in 1 min └Buying vol: 437.10K USDT 🟢 Boost score: 5/10 24h Vol: 14.92M USDT (Binance) Price: 0.2869 (-4.0% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243798 · 17.04.2026 г., 17:55

#WLD | Volume spike (USDT PAIR) 58 times the average volume 605.14K USDT traded in 1 min └Buying vol: 304.83K USDT 🟢 Boost score: 3/10 24h Vol: 14.92M USDT (Binance) Price: 0.2953 (-4.0% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243739 · 17.04.2026 г., 15:25

#WLD | Volume spike (USDT PAIR) 10 times the average volume 1.60M USDT traded in 15 min └Buying vol: 865.51K USDT 🟢 Boost score: 2/10 24h Vol: 14.92M USDT (Binance) Price: 0.3017 (-4.0% in 24h)

Hashtags

Crypto Headlines

@market_headlines · Post #28341 · 10.04.2026 г., 15:09

#wld 🧐 Ежедневная разблокировка WLD снижается. В World Network напоминают – с 24 июля темпы разблокировки токена WLD сократятся на ~43% (с ~5,1m до ~2,9m токенов в день). ➠ Токены сообщества: -50% (с 3,2m до 1,6m WLD/день). ➠ Токены команды и инвесторов: -32% (с 1,9m до 1,3m WLD/день). Разлок остается линейным (ежедневным), без «клиффов». На текущий момент разблокировано ~4,9b WLD (49% от максимальной эмиссии), из них ~3,3b уже в обращении. Crypto Headlines

Hashtags

American Crypto©

@americancryptotrading · Post #27598 · 24.04.2026 г., 08:59

🇺🇸#WLD/USDT is holding above the lowerborder of the fallingwedge on the 3D chart👨‍💻 Time to bounce and rally🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27531 · 11.02.2026 г., 10:51

🇺🇸#WLD/USDT has formed the descendingchannel on the weekly timeframe👀 A breakout will be huge✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27499 · 11.01.2026 г., 09:21

🇺🇸#WLD/USDT has found support at the midline of the descendingchannel formation on the weekly timeframe👨‍💻 A pump is expected✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27410 · 18.10.2025 г., 08:31

🇺🇸#WLD/USDT has printed the descendingchannel on the 3D chart👨‍💻 A bullish trend is unfolding📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27344 · 15.08.2025 г., 10:06

🇺🇸#WLD/USDT is maintaining its position above the lowerborder of the symmetricaltriangle formation on the daily timeframe👨‍💻 Recovery is on the way🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27260 · 25.05.2025 г., 09:33

🇺🇸#WLD/USDT is consolidating above the broken broadeningwedge pattern on the daily timeframe👀 Time to rise🚀 American Crypto©

Hashtags

123•••78
ПретходнаСтраница 1 од 8Следна