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

Резултати

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

Пребарај: #rif

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

@proanalysistrader · Post #28216 · 17.11.2024 г., 06:24

#RIF/USDT analysis : Following a significant decline of -83% from its all-time high, the price has found support at the $0.0600 level. Subsequently, it has bounced back and successfully broken above the trendline, indicating a confirmation of anticipated bullish momentum. It is expected that the price will continue this upward trajectory and test the previous swing high. TF : 1W Entry : $0.1117 Target : $0.3377 SL : $0.0766

Hashtags

Pro Analysis

@proanalysistrader · Post #27951 · 22.09.2024 г., 03:30

#RIF/USDT analysis : #RIF is trading above the support zone and the 200 EMA. The price is anticipated to rebound from this level and proceed to rise, testing the previous swing high. TF : 15min Entry : $0.0977 Target : $0.1007 SL : $0.0956

Hashtags

Alphavave Traders ️️️

@alphavave · Post #3256 · 21.04.2026 г., 00:34

#RIF yielded an impressive 3,010% return in a few days ⭐ If you used 200x leverage on this signal, you would've made a mind-blowing profit of 12,040%🤩 $50💰 would return $750💵 $50 💰 would return $1,500 💲 $50💰 would return $6,000💰 When you understand the market like we do, every move becomes predictable With 5+ years of trading experience, we spot these moves before they happen 💯 If you want daily signals like this, DM me to join our private group! 👇 @Kevindexter✅

Hashtags

Binance crypto champions

@binancecryptochampions · Post #3087 · 11.02.2026 г., 03:39

💎#RIF/USDT 💎 Signal Type: Regular (Long) Leverage: Cross (20.0x) Amount: 2.0% Entry Targets: 1) 0.04535 Take-Profit Targets: 1) 0.04635 2) 0.04800 3) 0.05065 Stop Targets: 1) 0.04250 🦋 Published by: @Trading_exp🦋 Join_vip: @Crypto_Futures_Spot_Payment_bot 🚫 Don't forget to Secure profit 🚫

Hashtags

Alex Kowalski | Trade

@kowalskitrade · Post #751 · 12.09.2024 г., 16:13

#RIF I'm expecting roughly this kind of movement on this asset, either with streaming start ups behind our magnets from above. 📈Sign up on Bybit to trade with me

Hashtags

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