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

Резултати

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

Пребарај: #coti

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

@proanalysistrader · Post #28427 · 26.01.2025 г., 14:53

#COTI/USDT analysis : #COTI is currently forming higher highs (HHs) and higher lows (HLs) along the trendline. The price is consolidating above this trendline, suggesting a potential bounce back and a test of higher levels. TF : 1W Entry : $0.10200 Target : $0.18200 SL : $0.07670

Hashtags

Pro Analysis

@proanalysistrader · Post #28282 · 29.11.2024 г., 11:03

#COTI/USDT analysis : #COTI is in an uptrend, forming a structure of higher highs (HHs) and higher lows (HLs). The price has broken out and successfully retested the trendline, continuing its bullish trajectory. Currently, the price is trading above a minor resistance zone, which has now become a buy zone. It is anticipated that the price will rise further and test higher levels. TF : 1H Entry : $0.14450 Target : $0.16145 SL : $0.13292

Hashtags

American Crypto©

@americancryptotrading · Post #27541 · 21.02.2026 г., 10:43

🇺🇸#COTI/USDT has found support at the lowerboundary of the descendingchannel pattern on the weekly timeframe💁‍♂️ Time to bounce and rally✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27488 · 01.01.2026 г., 11:17

🇺🇸#COTI/USDT is attempting to rebound from the lowerborder of the descendingchannel formation on the weekly chart🧐 More upside is likely🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27374 · 13.09.2025 г., 09:29

🇺🇸#COTI/USDT is on the verge of a breakout from the descendingchannel formation on the daily timeframe👨‍💻 The rally is coming📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27317 · 20.07.2025 г., 08:45

🇺🇸#COTI/USDT is holding above the lowerboundary of the descendingtriangle on the weekly chart👨‍💻 Up we go🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27185 · 15.03.2025 г., 14:32

🇺🇸#COTI/USDT is maintaining position above the lowerborder of the symmetricaltriangle formation on the weekly timeframe🔍 Strong upside potential on a bounce✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27181 · 11.03.2025 г., 14:22

🇺🇸#COTI/USDT is consolidating near the s/r zone on the weekly chart🧐 Bullish case if we bounce off the one🚀 American Crypto©

Hashtags

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