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

Резултати

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

Пребарај: #dmc

当前筛选 #dmc清除筛选
Free Crypto Signals (Profitable Zone)

@btctradingclub · Post #26669 · 31.12.2025 г., 18:48

🚀🚀 75% Profit on #DMC/USDT for our Premium Members on Binance Futures/Bybit/OKXX/Kucoin/Bitget ✅✅ All target completed - Trade Closed 👁‍🗨Contact @primemod to enter the Premium Group for high quality SPOT & FUTURES Signals

Hashtags

🚗DeLorean (DMC) Reward Pool on Bitget 🔥 June 24, 2025, 7:00 PM – June 26, 2025, 7:00 PM (UTC+8) During the event, stake your BGB or DMC tokens and share 66,176,000 DMC in rewards! About the $DMC project by DeLorean: 1️⃣Strategic Partnerships:DeLorean Labs is collaborating with the Sui Foundation and Mysten Labs, leveraging Sui’s high throughput to enable lightning-fast transactions ⚡️ 2️⃣ Brand Power: The iconic Back to the Future car meets Web3 — a nostalgic and compelling mix for fans and blockchain enthusiasts alike. 3️⃣Real-World Utility: Use $DMC to purchase the 🚗DeLorean Alpha 5 EV, limited editions, and exclusive merchandise. Future plans include luxury goods and expanded payment use cases. 4️⃣NFT Ecosystem: $DMC powers the DeLorean Labs marketplace — enabling collecting, reselling, and interactive experiences. 5️⃣Decentralized Governance: Holders of $DMC can vote on features, partnerships, and the future direction of the community. 🔌How to Join ➡️ Visit the staking page ➡️ Choose the $BGB or $DMC pool ➡️ Start staking and earn rewards 💵 Hop into the pool — and ride the crypto car of the future! #BackToTheFuture#web3#DMC

GRAYKOLORI 🧪💀

@graykolori · Post #741 · 24.04.2025 г., 16:31

Я так просто Саше не сдамся - тем временем я делаю уже Данте для другой студии 🌚 Видимо, теперь тоже придётся вставать в 4.30 утра Только лишь из принципа, правда?.. #kolori#анонс#dmc

Новости MICE backstage

@micebackstage · Post #850 · 18.09.2024 г., 13:16

📊Сообщество MICE Backstage опубликовало анализ своих участников! Мы провели исследование, чтобы выяснить, кто входит в наше сообщество, из каких стран они происходят, и каково процентное соотношение мужчин и женщин среди участников. Особое внимание уделили представителям компаний, активно участвующих в жизни сообщества. Интересные факты из исследования: - Представители компаний, работающих исключительно в сфере MICE, составляют 41,9%. - Представители DMC — 13,6%. - Корпоративные клиенты — 2,3%. - Event & MICE специалисты — 12,8%. - Представительство по маркетингу 4,9% 📊Больше данных и подробности на нашей инфографике! #MICE#MICEBackstage#АнализСообщества#СобытийныйМаркетинг#DMC#EventManagement

Auto Life

@revheadcrypto · Post #225 · 02.08.2024 г., 14:13

🚗💨 Exciting news from the German tuning atelier DMC! They've unveiled the first tuning kit for the stunning Lamborghini Revuelto! 🌟 This incredible kit features: ✨ Two different rear wings ✨ An alternative diffuser ✨ Side skirt overlays ✨ New side mirror housings The stock V12 engine delivers a jaw-dropping 1015 horsepower, but with DMC's modifications to the exhaust system and engine control unit, it now boasts an impressive 1099 horsepower! 🔥💪 And here's a twist: all parts from the kit will be available for purchase exclusively in Bitcoin! 💰💻 #Lamborghini#Revuelto#DMC#Tuning#Supercar#V12#Performance#Bitcoin#LuxuryCars#Auto