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

Резултати

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

Пребарај: #bubblemaps

当前筛选 #bubblemaps清除筛选
Airdrop Comic

@airdropcomic · Post #1910 · 24.03.2025 г., 09:54

🚀BubbleMaps (BMT) Airdrop is LIVE on Binance! 🎉 Earn FREE $BMT with Retroactive BNB SimpleEarn Subscriptions! If you held BNB in Simple Earn (Flexible/Locked) or On-Chain Yields (March 2 - 6, 2025) you may qualify! 🎁 🔥 Why BubbleMaps? ✔️ Track token movements & uncover hidden links 🔍 ✔️ Integrated with CoinGecko, DexScreener & more 💡 ✔️ BubbleMaps V2 unlocks new features with $BMT🚀 📈$BMT Trading Pairs on Binance: 🔹 BMT/USDT | BMT/USDC | BMT/BNB | BMT/FDUSD | BMT/TRY ⚙️ How to Participate? 📥Check Your Eligibility & Claim Here: 👉Register & Claim Now 📢Stay Updated & Join Our Community: 🔗BubbleMaps Official Telegram ®Note - Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens #BubbleMaps#BMT#Binance#Airdrop#Crypto

Venture Village Wall 🦄

@venturevillagewall · Post #3880 · 15.01.2025 г., 07:00

Simplifying Processes: A Billion-Dollar Idea A new startup aims to simplify image and video management, outperforming Dropbox. This innovation has attracted nearly $70 million in investments, capitalizing on a $2 trillion creative economy. Additionally, Bubblemaps has launched its BMT token on Solana, offering on-chain analytics and community governance, hinting at a potential airdrop. Deribit, a major crypto derivatives exchange, is exploring acquisition offers, valued between $4-5 billion, with Kraken showing interest. #Startup#Dropbox#Investment#CreativeEconomy#Bubblemaps#BMT#Token#Solana#Crypto#ETFs#Derivatives#Kraken#Airdrop#VC#AI#Blockchain#Innovation#Finance

Crypto M - Crypto News

@CryptoM · Post #65295 · 12.04.2026 г., 15:15

🚀 Crypto Analyst Manya Releases Research Tool Rankings Crypto analyst manya has released a ranking of personal research tools. According to ChainCatcher, the rankings categorize tools into different levels based on their effectiveness. The S-tier includes Dune and frontrun.pro, while the A-tier features Coinglass, RootData, Drop, MetaSleuth, and DefiLlama. B-tier tools comprise Arkham, Bubblemaps, Dexscreener, Surf, Nansen, and CoinMarketCap. C-tier tools include Cryptorank and others. #CryptoAnalyst#ResearchTools#CryptoRanking#Dune#frontrunpro#Coinglass#RootData#Drop#MetaSleuth#DefiLlama#Arkham#Bubblemaps#Dexscreener#Surf#Nansen#CoinMarketCap#Cryptorank