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

Резултати

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

Пребарај: #nextbigthing

当前筛选 #nextbigthing清除筛选
SingSing Announcement

@singsingchannel · Post #1050 · 24.11.2024 г., 02:05

🚀 Next week, the wait is over! 🎉 You'll officially be able to deposit $SING into the Tycoon Game and unlock its amazing utilities: 🔹 Pay fees for withdrawals 🔹 Cover transaction fees on the Marketplace 🔹 Buy $KARA in the shop 🔹 Use as a fee for wallet check-ins 🔹 List and trade NFTs on the Marketplace 🔹 Spin the Supreme Spin for massive rewards! 🔥 Hold onto your $SING and grab more while it’s still at a great price today. This won’t last long — soon, $SING will be in even higher demand! 💎 👉#SingSingTycoon#SING#NextBigThing 🎤Announcement | Chat | X (Twitter) | Website | Game

Crypto Fight || News 🚀

@cryptofightnews · Post #2916 · 20.09.2025 г., 08:55

🚨 Exclusive: $5M Raised in Phase 2 🚨 Royals & Whales are buying SHHEIKH. Price: $0.00405 with 5% bonus. Your early chance won’t last. 👉www.shheikh.io #Crypto#Blockchain#AI#RWA#DeFi#Tokenization#Altcoins#CryptoCommunity#CryptoInvesting#Presale#BullRun2025#NextBigThing

Crypto Fight || News 🚀

@cryptofightnews · Post #2910 · 18.09.2025 г., 07:52

🚀 Analyst Price Targets: $2–$5 Long Term 🚀 Royals see it. Whales see it. Do you? Buy at $0.00405 before it’s too late. 👉www.shheikh.io #Crypto#Blockchain#AI#RWA#DeFi#Tokenization#Altcoins#CryptoCommunity#Presale#BullRun2025#NextBigThing#Wealth

Airdrop Auditors

@airdropauditors · Post #5128 · 25.09.2025 г., 18:39

🚨 Presale Alert: SHHEIKH $SHHEIKH Is the Talk of the Town Royals are watching. Whales are buying. 🔥 Total Pool: $5.52M+ raised in Phase 2 already! AI + RWA = not just hype, but the future of finance. $0.00405 with 5% bonus. Time to move. 🔗 Presale Link:www.shheikh.io =========================== 📝 Tasks: 🔘 Follow their Twitter account 🔘 Join their Telegram Channel 🔘 Join their Presale =========================== 📅 End Date: 07 October 2025 🔴Note:Make sure to conduct thorough research (DYOR) before joining. Please note that this is not financial advice, and it's important to understand all risks involved beforehand. #Crypto#Blockchain#AI#RWA#DeFi#Altcoins#CryptoNews#Presale#Investing#BullRun2025#WealthBuilding#NextBigThing

Crypto Officer™

@cryptoofficer · Post #1568 · 09.10.2025 г., 02:39

📦New Project Spotlight: SHHEIKH Token 🔥 🪙 Phase 2 Live: $0.00405 + 5% Bonus 💎Rating: ⭐️⭐️⭐️⭐️⭐️ 🔗Participate now: www.shheikh.io =========================== 📣How to participate: ✅Visit www.shheikh.io ✅ Connect your wallet ✅ Purchase SHHEIKH tokens (Min: $10) ✅ Receive instant 5% bonus ✅ Follow their Twitter & Join Telegram =========================== 🖥SHHEIKH has raised $6.53M+ USDT and sold 2.05 BILLION tokens in Phase 2. Recognized as the #1 AI + RWA project of 2025, combining artificial intelligence with real-world asset tokenization. 🚨Why investors are watching: ✅Royals & whales accumulating positions ✅ $6.53M+ raised from global investors ✅ Analysts' top AI + RWA pick for 2025 ✅ Still early entry before phase closes #Crypto#Blockchain#AI#RWA#DeFi#Altcoins#Tokenization#BullRun2025#NextBigThing#Presale#Wealth#CryptoCommunity 🔴Note:Please do your own research (DYOR) before participating. This is not financial advice (NFA).

Airdrop Ninja™

@airdropsalertteam · Post #9466 · 09.10.2025 г., 02:41

📦Exclusive Project Spotlight: SHHEIKH Token 👑 🛍 Phase 2 Price: $0.00405 | Minimum: $10 USDT 💎 Status: Gaining Major Royal Attention 🔗Official Site: www.shheikh.io =========================== 📣How to Participate: ✅Visit www.shheikh.io ✅ Connect Your Wallet ✅ Purchase SHHEIKH Tokens ✅ Follow Twitter & Join Telegram =========================== 🔥SHHEIKH has raised $6.53M+ USDT with confirmed interest from Middle Eastern royal investors. This AI-powered RWA project represents real institutional momentum and technological innovation. 🚨Key Highlights: ✅$6.53M+ raised from global investors ✅Middle Eastern royals in active talks ✅ Real institutional power and backing ✅ Limited time remaining in Phase 2 #Crypto#Blockchain#AI#RWA#DeFi#Altcoins#Tokenization#Presale#CryptoCommunity#BullRun2025#Wealth#NextBigThing 🔴Note:Please do your own research (DYOR) before participating. Nothing in this post is financial advice (NFA).