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

Резултати

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

Пребарај: #mbox

当前筛选 #mbox清除筛选
Coin Sonar

@CoinSonar · Post #244164 · 18.04.2026 г., 12:08

#MBOX | Volume spike (USDT PAIR) 13 times the average volume 173.59K USDT traded in 15 min └Selling vol: 122.60K USDT 🔴 Boost score: 1/10 24h Vol: 1.22M USDT (Binance) Price: 0.0152 (-2.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #244112 · 18.04.2026 г., 10:08

#MBOX | Volume spike (USDT PAIR) 10 times the average volume 128.49K USDT traded in 15 min └Buying vol: 74.31K USDT 🟢 Boost score: 5/10 24h Vol: 1.22M USDT (Binance) Price: 0.0157 (-2.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #244047 · 18.04.2026 г., 07:48

#MBOX | Volume spike (USDT PAIR) 29 times the average volume 125.59K USDT traded in 5 min └Selling vol: 69.68K USDT 🔴 Boost score: 1/10 24h Vol: 1.22M USDT (Binance) Price: 0.0154 (-2.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243990 · 18.04.2026 г., 05:48

#MBOX | Volume spike (USDT PAIR) 10 times the average volume 131.44K USDT traded in 15 min └Selling vol: 66.19K USDT 🔴 Boost score: 1/10 24h Vol: 1.22M USDT (Binance) Price: 0.0142 (-2.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243446 · 17.04.2026 г., 04:47

#MBOX | Volume spike (USDT PAIR) 10 times the average volume 129.11K USDT traded in 15 min └Buying vol: 88.30K USDT 🟢 Boost score: 6/10 24h Vol: 1.22M USDT (Binance) Price: 0.0153 (-2.5% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28566 · 21.03.2025 г., 08:47

#MBOX/USDT analysis : #MBOX is currently in a downtrend, trading below the 200 EMA. The price has been rejected from the resistance zone and broken below the trendline. It is expected to decline further and test the swing low. TF : 2h Entry : $0.0845 Target : $0.0756 SL : $0.0900

Hashtags

Pro Analysis

@proanalysistrader · Post #28391 · 16.01.2025 г., 08:05

#MBOX/USDT analysis : #MBOX is in a downtrend, consistently making lower lows (LLs) and lower highs (LHs) below the 200 EMA. Currently, the price is retracing towards the 200 EMA and a resistance zone. It is anticipated that the price will test this zone before reverting back to continue its bearish momentum, potentially reaching lower levels. TF : 4h Entry : $0.1865 Target : $0.1566 SL : $0.2037

Hashtags

Pro Analysis

@proanalysistrader · Post #27984 · 04.10.2024 г., 13:28

#MBOX/USDT analysis : #Mbox is currently in a downtrend, trading below the 200 EMA. The price is forming a structure of lower lows and lower highs. It is facing rejection from the resistance zone, which suggests a potential reversal that could reinforce its bearish trend and test previous lows. TF : 15min Entry : $0.1332 Target : $0.1269 SL : $0.1366

Hashtags

American Crypto©

@americancryptotrading · Post #27460 · 05.12.2025 г., 10:37

🇺🇸#MBOX/USDT is bouncing from the support zone inside the descendingchannel pattern on the weekly chart🔍 Looks bullish✈️ American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27179 · 09.03.2025 г., 15:28

🇺🇸#MBOX/USDT has found support at the lowerborder of the descendingchannel pattern on the weekly timeframe👀 Looking for a rise🐃 American Crypto©

Hashtags

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