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

Резултати

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

Пребарај: #tokenlaunch

当前筛选 #tokenlaunch清除筛选

🚀 Top news! 🚀 We are launching the OCRO token with guaranteed growth - the price will rise from $0.02 to $0.10 in just 90 days from June 6th! 💥 And the best part: register with our exclusive link NOW and get a $50 gift as a thank you! 🎁 🔗 *https://octario.exchange/login/register?InvitationCode=833700* Join the future of crypto with guaranteed growth and cool bonuses! Don't miss your chance - join today! 🚀✨ #Crypto#TokenLaunch#OCRO#GuaranteedGrowth#Investments#CryptoCommunity#IEO

Venture Village Wall 🦄

@venturevillagewall · Post #4168 · 16.02.2025 г., 19:00

Argentina's Opposition Eyes Impeachment Over LIBRA Argentina's opposition is considering impeachment for President Milei after conflicting support for the LIBRA token. This follows a controversial launch that saw rapid investment and then a significant drop in value, leading to accusations of mismanagement and deception. The situation raises questions about political influence in cryptocurrency projects. Read more: Reuters #Argentina#LIBRA#Crypto#Impeachment#Milei#Investment#MarketManipulation#EconomicCrisis#Blockchain#DeFi#RugPull#Politics#Cryptocurrency#TokenLaunch#InsiderTrading#Securities#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4003 · 27.01.2025 г., 22:00

SEC Reviews Bitcoin and Ethereum ETFs Cboe BZX proposed rule changes to SEC for ARK 21Shares Bitcoin ETF and 21Shares Core Ethereum ETF, allowing in-kind creations and redemptions. Additionally, Venice, founded by Erik Voorhees, opened its API for AI development and launched the Venice token (VVV) with airdrop to over 250k users. DARPA initiated a pre-crime AML program to combat digital asset money laundering, raising concerns over discrimination. Kucoin pled guilty to unlicensed money transmitter charges, resulting in deferred prosecution agreements. Bitcoin prices fluctuating, with recent transactions indicating notable movements. More developments in the crypto market with potential implications on broader economic issues. 📈 Current Bitcoin price: $102,000. For more: Nate Geraci, Leviathan News, Leviathan News, Leviathan News #SEC#Bitcoin#Ethereum#ETF#Crypto#AI#VC#Venice#Kucoin#AML#DARPA#DigitalAssets#CryptoMarket#Investing#MoneyLaundering#FinancialRegulation#Cryptocurrency#TokenLaunch#TechInnovation#FutureFinance#MarketTrends

Venture Village Wall 🦄

@venturevillagewall · Post #4061 · 03.02.2025 г., 22:00

Major Bitcoin Moves & New Token Launch 🔹 Bitcoin reaches $101,898. 🔹 Leviathan’s Legal-Squid-in-Residence launches new token on flaunch.gg. 5% of the supply locked with GAIB BORG. 🔹 150,000,000 #USDT transferred to unknown wallet (worth $150,040,874). 🔹 59,000,000 #USDC minted at USDC Treasury. 🔹 Senator Lummis calls President Trump’s sovereign wealth fund order a '*₿ig deal*'. 🔹 Trump reportedly purchases 86,000 ETH for $220 million amidst market fears. Stay updated for more! #Bitcoin#USDT#USDC#Crypto#Finance#WealthFund#Lummis#Trump#ETH#TokenLaunch#GAIBBORG#Investment#WhaleAlert#MarketNews#SovereignWealth#Ethereum#Flaunch#Leviathan#TraderAlert#CryptoMarket

Venture Village Wall 🦄

@venturevillagewall · Post #4104 · 09.02.2025 г., 07:00

Pumpfun Launching Token via Dutch Auction Pumpfun, a Solana-based token launch platform, plans to conduct public offerings using the Dutch auction model. The initiative has garnered interest from CEXs for system development. Reports indicate Pumpfun has earned $572M in fees and transferred $386.8M to Kraken. However, ongoing lawsuits in the U.S. may affect its token issuance plans. Details were confirmed by the WuBlockchain team and insiders. #Pumpfun#Solana#TokenLaunch#DutchAuction#CEX#Binance#HeYi#Lawsuit#CryptoNews#Finance#Blockchain#Investing#ICO#IEO#MarketTrends#Fees#Kraken#Innovation#PublicOfferings#VC#AI

Venture Village Wall 🦄

@venturevillagewall · Post #3507 · 19.12.2024 г., 15:57

Monad Ecosystem's Rising Interest The Monad blockchain ecosystem is gaining attention ahead of its launch, focusing on community engagement and innovative projects. Key highlights include: - Event: Demo day showcased 20 projects, co-hosted by Paradigm with a $750k prize pool. - Projects: Noteworthy initiatives included: - Kizzy: A mobile betting platform based on Twitter events. - Sparkball: A team strategy game soon on Steam. - LootGO: A Walk2Earn project, previously overlooked. - Pulse: A health-monitoring bracelet securing $1.8M funding. - Community and Hype: Founders cite strong community support as a major attractor to Monad. - Future Vision: Excitement surrounds Monad’s upcoming testnet and potential partnerships with platforms like TON. #Blockchain#Monad#Crypto#Web3#Gaming#Social#Fundraising#EVMcompatible#Paradigm#DemoDay#Kizzy#Sparkball#LootGO#Pulse#NEOWIZ#Ethereum#Funding#TokenLaunch#Community#Hype