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

Резултати

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

Пребарај: #altcoins

当前筛选 #altcoins清除筛选
Coin Signals

@coin_signals · Post #16875 · 11.08.2025 г., 19:28

📊 There is no strength in the market; very few coins have posted double-digit returns in the past 7 days. First, LTC pumped, then ETH, and then BTC. The overall market is not trending upward together. (possibility of exit pumps) $BTC Bullish if holds above $121k. $ETH Bullish Right Now #Altcoins still Bearish.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4828 · 13.09.2024 г., 10:18

The markets are heating up for a strong October and November. That's why you want to be positioned into strong #Altcoins. $OM is one of them, only 24% down from the ATH, it's looking primed for a strong continuation in upcoming months.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4824 · 12.09.2024 г., 10:26

#Altcoins are doing relatively well. $SEI continues to find momentum, and I'd like to see it rally to $0.34 (preferably even above the previous high, but not expecting that yet), make an HL, and continue that rally to $0.44 in October.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4795 · 09.09.2024 г., 13:30

#Altcoins are doing great, silently. $OP has been gaining momentum, up 28% since the recent low. Rounded bottom with a 3-day bullish divergence. Needs to break through 2750-2850 sats, and then the divergence becomes valid. Expecting a big breakout.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4789 · 08.09.2024 г., 10:40

The #Altcoins show a potential bullish divergence on the Others/BTC chart. Very important, as that might be an indicator of what's going to come. The bottoming process is fully in place.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4787 · 07.09.2024 г., 16:08

Ethereum #altcoins aren't doing bad, as $OP is currently up from the lows. However, on the larger scale, it's currently down substantially and it's back to the lows. I'm expecting a lot more upside to come on this one once EigenLayer comes into action.

Hashtags

Michaël Van de Poppe Official

@michaelvandepoppeanalyst · Post #4776 · 06.09.2024 г., 16:52

#Altcoins aren't doing that wrong, as $SEI is currently looking at a crucial support test. I'd like to see $SEI stay above $0.24. If that's the case, we'll be good to go towards $0.45.

Hashtags

123•••10•••20•••2526
ПретходнаСтраница 1 од 26Следна