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

Пребарај: #shibarium

当前筛选 #shibarium清除筛选
SpotOnChain | Announcement

@spotonchain · Post #345 · 17.08.2023 г., 05:59

🚨#Shibarium encountered technical problem just 2 hours after its launch on Aug 17, 10 PM UTC (8 hours ago). We noticed: 1. Whale 0x00b smartly closed his $BONE deal right before the launch and the following price drop. • sold his last 146.9K $BONE for 237K $USDC at $1.612 8 hours ago (~the local peak) • Total profit from $BONE investment: $866K (+30.4%) 2. There are 964.46 $ETH ($1.73M) allegedly locked on the #Shibarium cross-chain bridge 👉 Link to the full article: https://platform.spotonchain.ai/signal-details/highlighted-activities-pre-and-post-the-launch-of-shibarium-network-468

Hashtags

SpotOnChain | Announcement

@spotonchain · Post #92 · 11.03.2023 г., 03:14

🤔🤔 Gigantic whale continues accumulating more $SHIB, it received a total of 382B $SHIB ($4M) in the last 24 hours. Likely he has a big bet on #shibarium Public Beta launching soon 🔥 The whale currently holds 20.4T $SHIB (~$213,8M) Address link: https://etherscan.io/address/0x73af3bcf944a6559933396c1577b257e2054d935

Hashtags

SpotOnChain | Announcement

@spotonchain · Post #52 · 23.02.2023 г., 03:46

🧐With #Shibarium launching, we detected some whales start accumulating $BONE. - These smart traders recently bought $SYN before its #Binance listing. 🤔Could $BONE be listed on larger exchanges ? Read more details below 👇 https://twitter.com/spotonchain/status/1628439005263167488

🚀🚀The intelligent investors💯💯

@the_intelligent_investors · Post #1064 · 04.09.2023 г., 13:20

🐾 Hey, #SHIBARMY, listen up! 📢 🚀🪐 Level up your crypto game with WOOFTools: the ultimate trading solution❣️ 📈 Real-time crypto prices? ✅ 💼 Easy DEFI portfolio management? 💥 🔔 Customizable price alerts? ✅ 💰 Exclusive rewards with $WOOFS? 🌐🇨🇳 Say goodbye to complicated platforms - WOOFTools has your back! 😎 🌐 Seamless integration, all in one place! No more jumping around. Trade like a pro with ease. Ready to rock the cryptocurrency world? 🔥🔥 Join the WOOFTools community now! The First DEX for #Shibarium in real time! 🌐 Website: https://wooftools.io 📢 Telegram: https://t.me/Woof_Tools 🇨🇳Chinese 💬: https://t.me/wooftoolsChinese $WOOFS will be released on IDO this Q3, early access on Telegram group ! Unleash your trading potential and stay ahead of the curve! 📈💥 #WOOFTools#Crypto#DeFi#TradingRevolution#ShibArmy #Shibarium Nfa DYOR

Ganar Dinero Seguro

@ganardineroseguro · Post #740 · 07.10.2021 г., 23:28

The Crypto Prophet (@ShibaProphet) Tweeted: The 2nd Parabolic is Starting Buckle up. It's going higher than before #Shiba#SHIB#ShibaCoin#SHIBARMY#shibainu#shibainu#ShibaSwap#SHIBDELETEAZERO#shibarium#ShibaProphethttps://t.co/uxWOszyTh5https://twitter.com/ShibaProphet/status/1446214042071277572?s=20