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

Пребарај: #standardchartered

当前筛选 #standardchartered清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #4281 · 01.03.2025 г., 22:00

Bitcoin Predicted to Reach $200K Soon Standard Chartered's Geoff Kendrick forecasts Bitcoin will hit $200K this year and could reach $500K before Trump exits the presidency. Predictions reflect growing confidence in BTC's potential growth trajectory. #Bitcoin#Crypto#Finance#Investment#Prediction#Market#Trump#StandardChartered#DigitalAssets#GeoffKendrick

Venture Village Wall 🦄

@venturevillagewall · Post #4172 · 17.02.2025 г., 10:00

Joint Venture for HKD-Backed Stablecoin Standard Chartered, Animoca Brands, and HKT have established a joint venture to issue a HKD-backed stablecoin under Hong Kong’s new regulatory framework. This collaboration will leverage Standard Chartered Bank (Hong Kong)'s robust infrastructure and governance. More details can be found here: Animoca Brands. #Stablecoin#HongKong#Finance#Crypto#VC#StandardChartered#AnimocaBrands#HKT#Regulation

Crypto M - Crypto News

@CryptoM · Post #64926 · 10.04.2026 г., 10:15

🚀 Stablecoin Joint Venture Model Dominated by Banking Sector A joint venture in the stablecoin sector is primarily led by the banking industry. According to PANews, Standard Chartered Bank (Hong Kong) holds a 50.5% stake, making it the majority shareholder. Animoca Brands owns 37.5%, while Hong Kong Telecom indirectly holds 12% through Quality Champion Limited. This structure reflects a model where the banking sector leads, with support from technology and telecommunications. #Stablecoin#JointVenture#BankingSector#StandardChartered#AnimocaBrands#HongKongTelecom#Telecommunications#Technology#Banking#Blockchain

Venture Village Wall 🦄

@venturevillagewall · Post #3835 · 10.01.2025 г., 04:00

Russia to Sell Seized Bitcoin Assets The Russian Ministry of Finance plans to sell seized Bitcoin assets from the Infraud hacking case, starting with a batch valued at approximately $10 million. Marat Tambiev, a corrupt official, previously obtained 1,032.1 BTC from the hacker group. Read more here. #Bitcoin#Russia#Infraud#Crypto#DigitalAssets#Banking#Finance#Regulation#MiCA#Custody#StandardChartered#EU#Hacking#Seizure#MaratTambiev#CryptoNews#BTC#Blockchain#FinanceNews#News

Venture Village Wall 🦄

@venturevillagewall · Post #3974 · 24.01.2025 г., 19:00

Big Moves in Crypto Regulation News 🚀 US Senator Cynthia Lummis, a vocal Bitcoin advocate, elected Chair of the Senate Digital Assets Committee. Proposed strategic Bitcoin reserve hints at potential significant moves for Bitcoin. Meanwhile, Trump's recent crypto executive order suggests a reserve of 'seized digital assets,' increasing speculation around Bitcoin's future. 🔗 For further details, read the article here. 🔗 In additional news, the SEC has opened the door for Wall Street banks to hold crypto. 🔗 Standard Chartered forecasts Bitcoin could reach $200,000 by the end of 2025. 🔗 Japan's Central Bank raised interest rates to a 17-year high, now at 0.5%, causing ripples across markets, including crypto. #Crypto#Bitcoin#US#Regulations#SEC#InterestRates#Japan#Senate#DigitalAssets#Investment#FinancialMarkets#WallStreet#Speculation#CynthiaLummis#CryptoBanks#PanteraCapital#StandardChartered#Ethereum#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4074 · 05.02.2025 г., 16:00

Crypto Market Faces Uncertainty, Analysts Warn Analysts predict further decline in the crypto market amid U.S. political uncertainty. Lack of progress on Bitcoin reserves and disappointing updates from David Sachs contribute to investor hesitance, say SkyBridge Capital's Anthony Scaramucci and QCP Capital experts. Yet, Standard Chartered forecasts Bitcoin may hit $500,000 during Trump's presidency. El Salvador recently added 11 BTC to its national Bitcoin reserve, totaling 6068 BTC. Medical firm Semler Scientific bought 871 BTC, raising its total to 3192 BTC. Additionally, Canadian company Neptune Digital Assets acquired 20 BTC, boosting their balance to 376 BTC. Meanwhile, MicroStrategy has paused further Bitcoin purchases after 12 consecutive weeks. For more details, visit: Forklog #Crypto#Bitcoin#TrumpsPresidency#SkyBridge#ElSalvador#SemlerScientific#NeptuneDigitalAssets#MicroStrategy#Investment#MarketAnalysis#QCPCapital#StandardChartered#BTC#CryptoMarket#PoliticalUncertainty#Blockchain#Investors#Reserve#Finance