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 слични објави

Пребарај: #henryakins

当前筛选 #henryakins清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1846 · 20.07.2025 г., 19:25

🔥NEW RELEASE🔥 😁No-Gi Guard Passing: The One Concept You Need To Pass Any Guard by Professor Henry Akins😁 ➡️If you’ve ever struggled with passing the guard in no-gi, this instructional is about to transform your game forever. ➡️In No-Gi Guard Passing, he distills decades of elite-level experience into a single, powerful concept that can be applied to every guard pass in the no-gi game. ̶$̶2̶7̶9̶😍$24.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #HenryAkins#Passing#NoGi#Gracie 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1924 · 13.03.2026 г., 21:18

😁Unpinable By Professor Henry Akins😁 ➡️Henry shares the same principles passed down directly from Rickson Gracie—details rarely taught in modern academies—that turn crushing top pressure into an opportunity to escape, reset, and dominate the pace of the match. ➡️If you want a calm, technical escape system rooted in the deepest levels of Brazilian Jiu-Jitsu, Unpinable by Henry Akins will permanently change how you experience bottom position. $279😍$24.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #HenryAkins#Transitions#NoGi#RicksonGracie 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1923 · 13.03.2026 г., 21:17

😁Learning How To Relax In Jiu-Jitsu By Professor Henry Akins😁 ➡️In Learning How to Relax in Jiu-Jitsu, legendary instructor Henry Akins reveals a groundbreaking approach to relaxation that transforms how you move, breathe, and apply technique on the mat. ➡️This course teaches you how to replace tension, panic, and wasted movement with structured breathing, intelligent pressure, precise timing, and effortless control $279😍$24.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #HenryAkins#Transitions#NoGi#RicksonGracie 💁‍♀️Buy 💁‍♀️