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

Резултати

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

Пребарај: #woo

当前筛选 #woo清除筛选
Pro Analysis

@proanalysistrader · Post #28000 · 10.10.2024 г., 03:47

#WOO/USDT analysis : #WOO is currently trading within a channel, and a retracement to the 200 EMA is pending. The price is likely to move upward and test the previous swing high resistance, with expectations for continued upward movement. TF : 1D Entry : $0.1629 Target : $0.2186 SL : $0.1469

Hashtags

American Crypto©

@americancryptotrading · Post #27577 · 03.04.2026 г., 09:16

🇺🇸#WOO/USDT is consolidating above the lowerborder of the fallingwedge on the 3D chart💁‍♂️ Rebound incoming✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27235 · 01.05.2025 г., 10:11

🇺🇸#WOO/USDT is breaching the descendingchannel formation on the daily timeframe🔥 Further rally is coming soon📈 American Crypto©

Hashtags

Coinlegs Cryptocurrency Signals

@coinlegs · Post #9547 · 15.12.2023 г., 10:06

#WOO Failure Swing Detection 👇 The chart fully and automatically generated by our algorithm. All drawings are based on only mathematical values and calculations instead of emotions. Interested? www.coinlegs.com

Hashtags

Crypto

@signal_bitcoins · Post #1802 · 12.12.2023 г., 07:19

#WOO bounced back from the Weekly Trendline and now hitted the Supply zone,in the case of breakout we will see another pump.🚀 otherwise wait to see the price reaction to the trendline again.👀 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

Mexc Crypto Signals Pumps Trading Kucoin

@mexc_signals_pumps_trading · Post #875 · 29.03.2024 г., 23:07

#WOO/USDT UPDATE: #WOO is now trading around 0.45$. #WOO has broken down of a bear flag on hourly time frame. Now the Possible scenario is according to the pattern, we can see 10-20% dump in this. Keep eye on it 👀Stay tuned with us for further updates✔️

Hashtags

Mexc Crypto Signals Pumps Trading Kucoin

@mexc_signals_pumps_trading · Post #871 · 28.03.2024 г., 18:58

#WOO/USDT UPDATE: #WOO is now trading around 0.454$. $WOO has formed a bear flag pattern on the hourly time frame. So the Possible scenario is If the price dumps and breaks down the pattern, we can see a dump in it. Keep eye on it👀. Stay tuned with us for further updates✔️

Hashtags

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