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

Резултати

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

Пребарај: #matic

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

@proanalysistrader · Post #27773 · 29.07.2024 г., 13:43

#MATIC/USDT analysis - #Matic is trading above the support zone and forming a rejection candle. It is expected to bounce off from there and test new highs. TF : 1D Entry : $0.5148 Target : $0.5740 & $0.6198 SL : $0.4579

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4650 · 28.08.2024 г., 09:38

#MATIC/USDT ANALYSIS MATIC has broken out of a falling wedge pattern with strong volume. It is currently undergoing a retest, and a successful retest would confirm a bullish reversal. However, if the retest fails, the pattern's validity will be nullified.

Hashtags

Crypto

@signal_bitcoins · Post #2863 · 17.02.2024 г., 16:35

💰#MATIC is losing bottom of the bullish channel on 1H Time frame,in the case of breakdown,it will drop until the Green zone 📉 ❄️@signal_bitcoins❄️ ❄️@Shadow_support0o❄️

Hashtags

Crypto

@signal_bitcoins · Post #2834 · 16.02.2024 г., 09:09

💰#MATIC has a Bullish flag pattern on Weekly time frame,now price is trying to break up the flag pattern👀 We expect another bullish trend will start after breakout and pullback💎 ❄️@signal_bitcoins❄️ ❄️@Shadow_support0o❄️

Hashtags

Crypto

@signal_bitcoins · Post #2496 · 24.01.2024 г., 16:42

💰#MATIC created a symmetrical triangle pattern successfully on Weekly time frame,we expect a huge drop on this chart 📉 Also we will buy it around $0.30 - $0.20✅ ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

Crypto

@signal_bitcoins · Post #2411 · 18.01.2024 г., 16:53

💰#MATIC price is near the bottom of bullish channel on 8H Time frame,if saved this area will have good pump again, atleast until ceiling of this pattern 💎 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

Crypto

@signal_bitcoins · Post #2038 · 26.12.2023 г., 16:35

💰#MATIC is trying to break up the Supply zone,we will wait for a pullback to the broken supply then will buy and hold✅ ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

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