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

Резултати

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

Пребарај: #garena

当前筛选 #garena清除筛选
APKPure_Official

@apkpurechannel · Post #2820 · 13.01.2026 г., 11:00

🚩🚀#Garena Free Fire OB52 | ❄️January 1️⃣4️⃣, 2026 📍⛩Jujutsu Kaisen Collab NEW!!✨ 🎮🕹Download #FF OB52 Update On Jan 14!! 🗓⏳The Countdown Is Almost Over!!! 1️⃣ Day Left To OB52 Update Official Release!!!⏰⏰⏰ 🔥🔥🔥Event Period: From【 Jan 14 】to【 Feb 13 】 Gear up and get ready for a cursed-energy surging battle!👊⚔️ Play as a true sorcerer and perform iconic techniques on the battlefield like a game master! 🏆🔥 🧐Free Fire OB52 Update Full Patch Notes 📌We'll let you know if there are any more new updates to FF via this channel, so stay tuned! Add @APKFreeDownloader_Bot to get any apk you want.

Hashtags

APKPure_Official

@apkpurechannel · Post #2517 · 02.07.2025 г., 01:46

🚩🚩Free Fire OB50 | #FF Schedule Leaks ⌛️🚀#Garena Free Fire OB50 Advance Server Goes Live July 6, 9AM (IST)!🔥🔥🔥 ⏰📅Free Fire #OB50 Official Game Expected to Release on July 31!🔥🔥🔥 👀 Mark your calendar and keep an eye out for the official release date! We will upload the 🎮latest version of Free Fire Advance Server APK once it is ready. OB50 details, click to check out: 🔍Everything you need to know about the upcoming OB50 We'll bring you more Garena news as soon as it becomes available, stay tuned! Add @APKFreeDownloader_Bot to get any apk you want.

BiA Cerámica Fría

@biaceramicafria · Post #4091 · 12.06.2023 г., 23:14

💳💳💳💳💳💳💳💳💳💳💳 ⚠️👾👾👾👾👾 ⚠️ 🔡🅰️🔡🔡🔡🔡🅰️ ✍️✍️✍️✍️✍️✍️✍️✍️ ✍️✍️✍️✍️✍️✍️✍️✍️✍️✍️ Adquiera una tarjeta digital prepagada VISA Vanilla y hágase con un método de pago versátil y sencillo de utilizar en cualquier plataforma donde se acepte Visa 💳 Precios en USD ✏️ ✏️➡️💲3️⃣3️⃣ ✏️ ✏️➡️💲6️⃣5️⃣ ✏️ ✏️ ✏️➡️💲1️⃣2️⃣6️⃣ ‼️🇨🇺 SERVICIO PARA TODA #CUBA🇨🇺‼️ Con nosotros podrá tener acceso a esas opciones de pago online que siempre quiso pero no tenía ni idea de que podía hacerlo desde Cuba Acceso a características Premium en aplicaciones de Diseño y Edición, suscripciones a almacenamiento en la nube, números extranjeros de teléfono virtuales, VPN en cualquier ubicación del mundo, software de producción de audio e imagen, desarrollo web, coding, etc ¡Libros, televisión y música online, videojuegos! Podemos hacerle llegar suscripciones, códigos y tarjetas digitales de saldo a sus cuentas en... 🛒#Amazon#Prime 📱#Apple#iTunes 🎮#Battlenet (#Blizzard's World of Warcraft #WoW) ℹ#Dota2 🎮#Garena 🕹#LeagueofLegends 📺#Netflix 🎮#Nintendo 🎮#Origin 🎮#PlayStation Network #PSN 🎮#Riot 🎵#Spotify 🎮#STEAM 💬#Telegram#Premium 📺#Twitch 🎮#Xbox Live 🇨🇺#Remesas#Pagos 📱 Tenemos alternativas para los pagos dentro de la Google Play Store con acceso a Google One y al Play Pass 📱 Contáctenos por #Telegram, por #Google, #Facebook, #Instagram, #Twitter y por #WhatsApp 💬@jcslimcuba 💬https://wa.me/5353717679 🌐https://m.me/jcslimcuba.fb ☎️ +5353717679 🖥https://linktr.ee/jcslimcuba #saldodesteam#steamwallet#cuba#psn#battlenet#steam#apple#steamgiftcard#jcslimcuba#giftcards#appleitunes#tarjetasderegalo#steamcuba#fortnite#Amazon#amazonmusic#amazonprime#primevideo#promo#visa#vanilla