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

Резултати

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

Пребарај: #bch

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

@CoinSonar · Post #243359 · 16.04.2026 г., 23:33

#BCH | Volume spike (USDT PAIR) 62 times the average volume 298.52K USDT traded in 1 min └Buying vol: 217.59K USDT 🟢 Boost score: 6/10 24h Vol: 6.91M USDT (Binance) Price: 455.2 (-1.8% in 24h)

Hashtags

American Crypto©

@americancryptotrading · Post #27574 · 31.03.2026 г., 09:39

🇺🇸#BCH/USDT is about to break through the ascendingtriangle on the 2W timeframe👀 Bullish📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27492 · 05.01.2026 г., 09:52

🇺🇸#BCH/USDT is currently trading above the symmetrical triangle formation on the 2W timeframe👨‍💻 Looking for a rise🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27446 · 22.11.2025 г., 16:18

🇺🇸#BCH Bitcoin Cash is pressing against the upper boundary of the macro ascending channel on the weekly timeframe 📈 Price continues to build higher lows while grinding toward resistance — a classic sign of strength inside a rising structure. Once BCH breaks through the channel top, momentum can accelerate sharply, opening the door for a major continuation move 🚀 The chart is bullish — BCH is preparing for the next expansion leg. American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27403 · 11.10.2025 г., 10:40

🇺🇸#BCH/USDT is consolidating above the symmetricaltriangle pattern on the weekly chart💁‍♂️ The bullish outlook remains intact🚀 American Crypto©

Hashtags

Free Crypto Signals (Profitable Zone)

@btctradingclub · Post #26960 · 22.02.2026 г., 09:58

🔰#BCH Update - Price is pushing higher after the recent bounce. Keeping a close watch on $603, which remains a key upside target on this leg up, as it aligns with the yearly open — a significant level that often acts as strong resistance.

Hashtags

Free Crypto Signals (Profitable Zone)

@btctradingclub · Post #26416 · 24.11.2025 г., 12:01

✅✅ 30% Profit on #BCH/USDT for our Premium Members on Binance Futures/Bybit/OKX & KuCoin 👁‍🗨Contact @primemod to enter the premium group & make daily gains on Futures/Bybit/OKX/Kucoin & Bitget market

Hashtags

Free Crypto Signals (Profitable Zone)

@btctradingclub · Post #26415 · 24.11.2025 г., 08:40

✅✅ 38% Profit on #BCH/USDT for our Premium Members on Binance Futures/Bybit/OKX & KuCoin 👁‍🗨Contact @primemod to enter the premium group & make daily gains on Futures/Bybit/OKX/Kucoin & Bitget market

Hashtags

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