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

Резултати

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

Пребарај: #shiba

当前筛选 #shiba清除筛选
Airdrop Presents 🗽

@airdrop_presents · Post #2204 · 19.01.2023 г., 15:49

🪂Airdrop ~ Shiba Inu (SHIB) 💲Reward: 150 Million #Shiba inu 💎 Presents Ratings: ⭐️⭐️⭐️ 👑Winners: 1,000 Lucky winners ➡️ Airdrop Page For Coingabbar 📚 How to Join Airdrop? ↪️ Signup at Coingabbar & Verify your Email to get 100k Cubs ↪️ Submit earned cubs for conversation, (1 Cub = 2 SHIB) Earn More Cubs Download the Android App/ IOS App ✏️Notes: Make sure to complete all tasks to receive rewards. ℹ️Distribution date: Will be announced by the project team after 28t-h January.

Hashtags

Alphavave Traders ️️️

@alphavave · Post #2149 · 20.05.2025 г., 12:51

Look at #SHIBA now! 💰🔥 Went from2,590%to 4,135%, that's 1,545% extra profit just by holding it a bit more A nice 41X return from this single Signal⭐ 🔸$50 would return $2,060💸 💰$50 would return $1,375💸 Enjoy 4,100% profit🆙. 🤝Congratulations allPremium Members. Now imagine if you followed the rest of the signals.. 🤑💯 We keep printing money, day after day 💯 Don't miss out - join us and start sending those gains to your bank 👇 @Kevindexter✅

Hashtags

Alphavave Traders ️️️

@alphavave · Post #2013 · 03.05.2025 г., 01:29

💰#SHIBA just smashed 2️⃣ 5️⃣ 🔠gains!Another big win, no surprise there 😌 It's business as usual - every day, like clockwork, we are in the fast lane, leaving the competition eating our dust 💰💸 We keep printing money, day after day 💯 Don't miss out - join us and start sending those gains to your bank 👇 @Kevindexter✅

Hashtags

SIGNAL

@finsignal · Post #3455 · 09.08.2024 г., 19:41

🐶 .Shizarium is getting ready for hardcore with a new version of Bor. 🧡The update will add a burning mechanism: 70% of the base fees will be converted into $SHIB tokens and removed from circulation, which may increase their price. The rest of the fees will be used to develop the ecosystem. 💡 And also announced the launch of #Shiba Eternity #Web3.

Hashtags

SIGNAL

@finsignal · Post #3408 · 24.07.2024 г., 11:08

🥸 Above is a 10-year chart of significant #altcoins and the number of non-empty wallets (#hodlers) in the corresponding networks: #Litecoin: 8.08M wallets #Dogecoin: 6.69M wallets #XRP Ledger: 5.24M Wallets #Cardano: 4.48M Wallets #Shiba Inu: 1.39M wallets #Chainlink: 722K wallets

Maximalist🍋🍋🍋

@maximalist_1 · Post #627 · 30.08.2024 г., 09:23

Данные от Santiment: 10 крупнейших кошельков удерживают значительные доли в крупнейших альткоинах, что подчеркивает проблему централизации в крипте: #Polygon (MATIC): 69.4% #Shiba Inu (SHIB): 61.2% #Uniswap (UNI): 50.8% #Pepe (PEPE): 46.1% #Ethereum (ETH): 44.0% #Tether (USDT): 33.1% #Chainlink (LINK): 31.1% #Toncoin (TON): 27.5% #Multi Collateral Dai (DAI): 24.5% #USD Coin (USDC): 19.0% 💬Мнение : Такая концентрация может повлиять на рынок, так как несколько крупных игроков могут существенно влиять на цену и ликвидность этих активов. #КриптоНовости#обзоррынка

12
ПретходнаСтраница 1 од 2Следна