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

Пребарај: #inflow

当前筛选 #inflow清除筛选
ScorpionX | Finance

@scorpionx_co · Post #730 · 21.12.2024 г., 09:24

حدود 1،240،000،000 تا ارز USDC دیروز به صرافی‌های اسپات وارد شدن. چرا؟ تا از این اصلاح به وجود اومده استفاده کنن و خرید بزنن. #USDC #Inflow #OnChain #Exchange @ScorpionX_Co☑️

Crypto M - Crypto News

@CryptoM · Post #65251 · 12.04.2026 г., 10:15

🚀 Bitcoin ETFs See Strong Inflows as Market Interest Grows US spot Bitcoin ETFs experienced significant net inflows exceeding $786 million last week, marking their most robust performance since February. According to NS3.AI, BlackRock's iShares Bitcoin Trust attracted approximately $612 million. Meanwhile, Morgan Stanley's newly launched MSBT fund garnered around $46 million within its initial three trading days. #Bitcoin#ETFs#BlackRock#MorganStanley#CryptoInvestment#MarketInterest#MSBT#iShares#Inflow#BTC

Crypto M - Crypto News

@CryptoM · Post #65369 · 13.04.2026 г., 02:54

🚀 XRP Spot ETFs See Significant Inflows and Outflows XRP spot ETFs experienced notable financial movements last week, with a net inflow of $11.75 million, according to Odaily. The data, sourced from SoSoValue, covers the trading days from April 6 to April 10 (Eastern Time). The Bitwise ETF XRP led the inflows, attracting $9.5154 million, bringing its historical total net inflow to $388 million. Following this, the Franklin ETF XRPZ saw a weekly net inflow of $2.8987 million, with its historical total reaching $324 million. Conversely, the 21Shares ETF TOXR recorded the highest net outflow, amounting to $661,200, with its historical total net outflow standing at $25.85 million. As of the latest update, the total net asset value of XRP spot ETFs is $968 million, with an ETF net asset ratio of 1.16% compared to XRP's total market capitalization. The cumulative historical net inflow has reached $1.22 billion. #XRP#ETFs#Crypto#Inflow#Outflow#Bitwise#Franklin#21Shares#NetAssetValue#MarketCap

Venture Village Wall 🦄

@venturevillagewall · Post #3680 · 24.12.2024 г., 08:10

Investments Surge in Innovative Platforms A startup has raised nearly $50 million after seven years of self-funding, initiating a trend of significant investment in platforms that facilitate companies selling third-party services. Notably, similar platforms across various sectors have also attracted large funding this year, signaling a ripe market for investment in this area. In addition, recent reports highlight key developments in the tech sector, such as a sharp decline in YouTube traffic in Russia, the purchase of advertising services by ‘Avito’ and T2, and the closure of electric aircraft startup Lilium after failing to secure funding. Moreover, European AI startups have attracted $13.7 billion in venture capital this year, comprising 25% of the continent's VC funding. Read more about these developments here: https://fastfounder.ru/takaja-shema-raboty-rezko-stala-vostrebovannoj/ #Startup#Investment#Funding#Platforms#AI#Tech#YouTube#AdTech#Lilium#VentureCapital#Ethereum#Tether#Rumble#Advertising#MarketTrends#Growth#FinTech#Crypto#Inflow#Development#EuropeanMarket