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

Пребарај: #pricetarget

当前筛选 #pricetarget清除筛选
Crypto M - Crypto News

@CryptoM · Post #65264 · 12.04.2026 г., 12:12

🚀 XRP's Triangle Breakout Sets $2.59 Price Target, Analyst Says Crypto analyst Dark Defender has highlighted a potential price target of $2.59 for XRP following its weekly triangle breakout. According to NS3.AI, Dark Defender noted that the cryptocurrency could find support at key Fibonacci levels of $1.31 and $1.37, provided it maintains its position above the previous resistance. #XRP#TriangleBreakout#PriceTarget#Crypto#DarkDefender#Fibonacci#NS3AI#Cryptocurrency

Crypto M - Crypto News

@CryptoM · Post #65292 · 12.04.2026 г., 15:13

🚀 Amazon's AI Investment Could Boost Stock by Over 50%, Analyst Predicts BNP Paribas Exane analyst Nick Jones has set a price target of $320 for Amazon, suggesting a potential upside of more than 50% from its April 7 closing price of $213.77. According to NS3.AI, Jones believes that Amazon's planned $200 billion investment in artificial intelligence by the end of 2026 is justified by increasing demand, backlog growth, and the broader deployment of AI across Amazon's product offerings. #Amazon#AI#Stock#Investment#BNPParibas#PriceTarget#ArtificialIntelligence#NS3AI#MarketGrowth#AmazonStock

Crypto M - Crypto News

@CryptoM · Post #64777 · 09.04.2026 г., 22:14

🚀 TD Cowen Adjusts Price Targets for Strategy and Sharplink TD Cowen has revised its price target for Bitcoin treasury firm Strategy to $350. According to NS3.AI, the financial services company also initiated coverage on Ethereum treasury company Sharplink with a 'buy' rating and set a price target of $16. TD analysts expressed confidence that Sharplink's staking revenue would be sufficient to cover its operating costs, even if Ethereum's market performance remains subdued. #TDCowen#PriceTarget#Bitcoin#Strategy#Sharplink#Ethereum#StakingRevenue#FinancialServices#Cryptocurrency#InvestmentAnalysis#BTC#ETH

Venture Village Wall 🦄

@venturevillagewall · Post #3932 · 20.01.2025 г., 19:00

Bitcoin Surges to New All-Time High Bitcoin jumps past $109,000, breaking out of a descending triangle pattern. Analysts predict a bullish trend, targeting $130,000 to $175,000 soon. Michael Egorov extends veCRV lock to maximum duration. #Bitcoin#Crypto#VC#Trading#TechnicalAnalysis#veCRV#Egorov#Bullish#MarketUpdate#BTC#PriceSurge#EconomicForecast#Cryptocurrency#Blockchain#CryptoMarket#Investments#PriceTarget