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

Резултати

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

Пребарај: #fet

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

@proanalysistrader · Post #28270 · 27.11.2024 г., 07:56

#FET/USDT Analysis- The price has formed a symmetrical triangle pattern. Given the current bullish market scenario, there is a high probability of an upward breakout. If the breakout occurs, the price is likely to rally toward the target zone from the breakout point. T.F.- 1-D ENTRY- as soon as it gives breakout SL- 1.2 TARGET- 2.04 Note: If the stop-loss is triggered before entry, disregard the trade as the price action may develop differently.

Hashtags

Pro Analysis

@proanalysistrader · Post #27893 · 31.08.2024 г., 17:52

#FET/USDT analysis : #FET has broken down the 200 EMA and previous support levels. It is now undergoing a pullback and retesting the resistance zone. The price is expected to reject from there and bounce back to continue its bearish momentum. TF : 1H Entry : $1.170 Target : $1.057 SL : $1.252

Hashtags

American Crypto©

@americancryptotrading · Post #27518 · 29.01.2026 г., 11:04

🇺🇸#FET/USDT is facing the lowerboundary of the descendingchannel formation on the weekly chart🧐 Looks bullish✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27482 · 27.12.2025 г., 09:39

🇺🇸#FET/USDT is trading near the lowerborder of the descendingchannel formation on the 2W chart💁‍♂️ A great moment to accumulate🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27370 · 10.09.2025 г., 09:48

🇺🇸#FET/USDT is trading within the descending channel formation on the 3D chart🧐 More upside if a breakout occurs📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27280 · 14.06.2025 г., 12:10

🇺🇸#FET/USDT is hovering above the broken s/rzone on the weekly chart🔍 Looking for a bounce✈️ American Crypto©

Hashtags

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