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

Резултати

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

Пребарај: #xlm

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

@proanalysistrader · Post #28537 · 13.03.2025 г., 03:30

#XLM/USDT analysis : #XLM is in an uptrend, trading above the 200-day EMA on the daily timeframe. The price has tested the support zone and 200-day EMA, and it is expected to rebound from the current level and move upside to test higher levels. For a long entry, wait for the price to break above the $0.2760 level. TF : 1D Entry : $0.2764 Target : $0.6374 SL : $0.2094

Hashtags

Pro Analysis

@proanalysistrader · Post #28490 · 21.02.2025 г., 15:22

#XLM/USDT analysis : #XLM is in an uptrend, forming higher highs (HHs) and higher lows (HLs) above the 200 EMA. The price has retested the 200 EMA and is anticipated to rebound, resuming its bullish momentum to test swing high levels. For a long entry, it is recommended to wait for a breakout above the $0.3751 level. TF : 1D Entry : $0.3751 Target : $0.6374 SL : $0.2764

Hashtags

Pro Analysis

@proanalysistrader · Post #27761 · 17.07.2024 г., 17:09

#XLM/USDT analysis - #XLM recently broke above the 200 EMA with strong momentum. The next move might be a retest of this level and a test of the support zone. Look for a pullback near the 200 EMA for a potential long entry. The previous resistance zone could serve as the target level. TF : 4h Entry : $0.0937 Target : $0.1198 SL : $0.0863

Hashtags

American Crypto©

@americancryptotrading · Post #27579 · 05.04.2026 г., 09:35

🇺🇸#XLM/USDT is currently forming the descendingchannel formation on the 3D timeframe🔍 Accumulate before the rocket takes off✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27489 · 02.01.2026 г., 10:30

🇺🇸#XLM/USDT is trading inside the descendingchannel on the 2D chart👨‍💻 Bullish on a breakout🚀 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27390 · 28.09.2025 г., 08:30

🇺🇸#XLM/USDT is holding above the broken s/rzone on the daily chart🔥 Bullish📈 American Crypto©

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна