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

Резултати

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

Пребарај: #shib

当前筛选 #shib清除筛选
Coin Sonar

@CoinSonar · Post #243269 · 16.04.2026 г., 18:53

#SHIB | Volume spike (USDT PAIR) 9 times the average volume 488.35K USDT traded in 15 min └Selling vol: 255.32K USDT 🔴 Boost score: 1/10 24h Vol: 4.72M USDT (Binance) Price: 0.00000635 (-4.2% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28511 · 02.03.2025 г., 16:57

#SHIB/USDT analysis : The price of #SHIB has recently broken out of its trendline, indicating a potential bullish momentum. While a retracement to the 200 EMA is expected, the overall sentiment suggests that the price is likely to move upwards and test the swing high level. TF : 4h Entry : $0.00001480 Target : $0.00001734 SL : $0.00001313

Hashtags

Pro Analysis

@proanalysistrader · Post #28225 · 19.11.2024 г., 12:45

#SHIB/USDT analysis : #SHIB has successfully broken out of the trendline, demonstrating a strong bullish movement. It is anticipated that this upward momentum will continue, allowing the price to test higher levels. TF : 1D Entry : $0.00002536 Target : $0.00004567 SL : $0.00001827

Hashtags

American Crypto©

@americancryptotrading · Post #27615 · 10.05.2026 г., 08:40

🇺🇸#SHIB/USDT is facing the upperboundary of the fallingwedge pattern on the 3D timeframe👨‍💻 A confirmed breakout could lead to massive gains🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27392 · 30.09.2025 г., 09:24

🇺🇸#SHIB/USDT has retested the upperborder of the fallingwedge pattern on the 2D chart🧐 The rally is coming🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27334 · 06.08.2025 г., 09:08

🇺🇸#SHIB/USDT is currently trading at the s/rzone on the weekly chart👀 Bullish mode is on if we bounce📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27206 · 04.04.2025 г., 21:47

🇺🇸#SHIB/USDT is trading within the descendingchannel pattern on the daily timeframe🔍 Looks bullish📈 American Crypto©

Hashtags

Coinlegs Cryptocurrency Signals

@coinlegs · Post #9982 · 24.02.2024 г., 08:21

#SHIB -%5 in 6hrs 🤑🤑 Algorithmic bots on our Discord server print us instant money. Thanks to Hey CoinLegs signals, we were able to catch short-term signals instantly. Join us to get access to these and many other algorithmic auto signals 👇 https://discord.gg/8RKtAA9cxZ

Hashtags

ПретходнаСтраница 1 од 5Следна