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

Резултати

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

Пребарај: #premium

当前筛选 #premium清除筛选
TN MiniCrypto Official

@swift_airdrops · Post #5092 · 24.03.2024 г., 14:29

🎉 Goblinium Airdrops Rewards $10,000 TON and GOBLIN Instant Join Bot fast :- https://t.me/GobliniumBot?start=mc_p2fhtnuxkcio 👉 Chart :- https://www.geckoterminal.com/ton/pools/EQCxWPtqCaBGBkLHuwzpJaL4mX9gLigA98nlO90XrCNee5NB #Premium ONLY 🔥

Hashtags

Meta Arts

@behzod_nazirov · Post #2622 · 09.12.2025 г., 10:46

🎞 YOUTUBE KANAL OCHISH XIZMATI #PREMIUM 🇺🇿🇺🇸O'zbekcha va Amerikan kanal ochib beramiz! ✅ Kanal uchun yo'nalish tanlashda yordam beramiz ✅ Kanal uchun original nom o'ylab topamiz ✅ Kanal ochamiz va to‘liq sozlab chiqamiz ✅ Standart Banner va Avatarka ishlab beramiz ✅ Telefon raqam bilan tasdiqlab beramiz 🧑‍💻 1 OYLIK NAZORAT: 30 kun davomidaadmin — kanalingizni kuzatib, nazorat qiladi va savollaringizga javob beradi! 🎁 BONUS: “VIGETA PRIVATE” yopiq kanalimizga 1 oylik tekin a’zolik🎁 💰 Narx: 349 000 so‘m ⏰ Topshirish muddati: 2 kun 🛒Buyurtma berish: ✍️@Vigeta_Admin ✅ 300 dan ortiq kanallarni muvaffaqiyatga boshladik — navbat sizniki! ➖➖➖➖➖➖➖ 😎VIGETA | BLOGERLAR UCHUN

Hashtags

Crypto

@signal_bitcoins · Post #2027 · 26.12.2023 г., 11:24

#Premium💸 The world of crypto and particularly futures trading is a beautiful world. 💎 Detailing a profitable trade requires a great team. We provide all this for you with pay a small fee in a VIP channel. Join us👉@shadow_crypto_bot

Hashtags

Crypto

@signal_bitcoins · Post #1962 · 22.12.2023 г., 15:05

#Premium🔥🔥 The world of crypto and particularly futures trading is a beautiful world. 💎 Detailing a profitable trade requires a great team. We provide all this for you with pay a small fee in a VIP channel. Join us👉@shadow_crypto_bot

Hashtags

Crypto

@signal_bitcoins · Post #1814 · 12.12.2023 г., 18:29

#Premium🔥🔥 The world of crypto and particularly futures trading is a beautiful world. 💎 Detailing a profitable trade requires a great team. We provide all this for you with pay a small fee in a VIP channel. Join us👉@shadow_crypto_bot

Hashtags

Crypto

@signal_bitcoins · Post #1761 · 08.12.2023 г., 17:10

#Premium🔥 The world of crypto and particularly futures trading is a beautiful world. 💎 Detailing a profitable trade requires a great team. We provide all this for you with pay a small fee in a VIP channel. Join us👉@shadow_crypto_bot

Hashtags

Crypto

@signal_bitcoins · Post #1754 · 08.12.2023 г., 14:24

#Premium💰 STOP losing money trading alone STOP telling yourself every time that you will make it back, but every time you lose it all. STOP letting opportunities pass you by. 💯One of our signals is always more than 100%, which means x2 to the deposit. 💎join us to enjoy our signals💎

Hashtags

Crypto

@signal_bitcoins · Post #1460 · 07.09.2023 г., 17:25

🔥#Premium🔥 PNL Report: AUGUST, 2023 MONTHLY STATS Total Trades: 40 Profitable Trades: 40 Losses: 0 Lifetime Accuracy: 100% Total Profit (No Leverage): 336.15%✅ Total Profit (With Leverage): 6723%✅ join #Premium👇🏻 💫@shadow_crypto_bot

Hashtags

Crypto

@signal_bitcoins · Post #1288 · 06.08.2023 г., 18:42

#Premium The world of crypto and particularly futures trading is a beautiful world. 💎 Every day, absolutely every day, there are huge opportunities to make money.💸 Join our community now to take advantage of our exceptional signals and to finally be able to make a lot of money with crypto. 🤑 🌟join us to enjoy our signals🌟

Hashtags

Telegram Info Indonesia

@tginfoid · Post #1054 · 25.12.2025 г., 11:05

Bot Dukungan Resmi Smart Glocal Beberapa waktu lalu, pengguna menemukan bot @tgpb_support_bot, yang memiliki tanda centang verifikasi resmi dan dirancang untuk menangani pertanyaan terkait pembayaran langganan Telegram Premium yang dilakukan melalui @premiumbot. Bot ini dapat berguna bagi pengguna yang telah membayar langganan melalui @premiumbot tetapi belum melihatnya muncul di akun mereka. #premium

Hashtags

123•••10•••20•••30•••3738
ПретходнаСтраница 1 од 38Следна