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

Резултати

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

Пребарај: #etfs

当前筛选 #etfs清除筛选
Crypto Media

@crypto_medias · Post #1521 · 21.02.2025 г., 18:29

🗽👀 A WAVE OF CRYPTOCURRENCY #ETFS AWAITING REGULATORY APPROVAL. WHICH ETF WILL BE APPROVED NEXT?

Hashtags

SIGNAL

@finsignal · Post #3203 · 05.06.2024 г., 12:54

Yesterday, the inflow into spot #Bitcoin#ETFs amounted to ~$886.75 million — this is the second largest one-day net inflow in history.

SIGNAL

@finsignal · Post #2735 · 26.12.2023 г., 08:56

⚡️ Arthur Hayes' essay "Expression" The main theses: If the #ETFs managed by TradFi are too successful, they will completely destroy #Bitcoin If $BTC becomes just another financial asset controlled by the state, it will die Because of their confusion and laziness, people buy Bitcoin ETF derivatives, rather than buying and storing bitcoins in their own wallets.

SIGNAL

@finsignal · Post #3402 · 21.07.2024 г., 14:44

💎 American issuers of spot #Bitcoin#ETFs have accumulated more than 900,000 #BTC ($60 billion) — this is 4.3% of the total issue of the first cryptocurrency.

SpotOnChain | Announcement

@spotonchain · Post #1233 · 02.07.2025 г., 06:08

🇺🇸 Spot ETF: 🔴$342.2M to $BTC and 🟢$40.7M to $ETH 🗓 July 1, 2025 👉 BTC ETFs saw the first net outflow after 15 consecutive trading days of net inflows. 👉 ETH ETFs is on a 3-day streak of net inflows, totalling $150M. Follow @spotonchain for the latest updates about #Bitcoin and #Ethereum#ETFs now!

SpotOnChain | Announcement

@spotonchain · Post #1231 · 01.07.2025 г., 08:30

🇺🇸 Spot ETF: 🟢$102.1M to $BTC and 🟢$31.8M to $ETH 🗓 June 30, 2025 👉 BTC ETFs have seen 15 consecutive net inflows, totalling +$4.734B. Follow @spotonchain for the latest updates about #Bitcoin and #Ethereum#ETFs now!

SpotOnChain | Announcement

@spotonchain · Post #1226 · 25.06.2025 г., 04:38

🇺🇸 Spot ETF: 🟢$588.6M to $BTC and 🟢$71.3M to $ETH 🗓 June 24, 2025 👉 BTC ETFs extended their streak of net inflows to 11 trading days, totaling +$3.354B. 👉 ETH ETFs have seen 2 consecutive net inflows, with $172M added. Follow @spotonchain for the latest updates about #Bitcoin and #Ethereum#ETFs now!

SpotOnChain | Announcement

@spotonchain · Post #1222 · 19.06.2025 г., 08:12

🇺🇸 Spot ETF: 🟢$388.3M to $BTC and 🟢$19.1M to $ETH 🗓 June 18, 2025 👉 BTC ETFs have seen net inflows for 8 consecutive trading days, totaling +$2.408B. 👉 ETH ETFs also extended their streak of net inflows to 3 trading days. Follow @spotonchain for the latest updates about #Bitcoin and #Ethereum#ETFs now!

SpotOnChain | Announcement

@spotonchain · Post #1220 · 18.06.2025 г., 07:49

🇺🇸 Spot ETF: 🟢$216.5M to $BTC and 🟢$11.1M to $ETH 🗓 June 17, 2025 👉 BTC ETFs have seen net inflows for 7 consecutive trading days, totaling +$2.02B. Follow @spotonchain for the latest updates about #Bitcoin and #Ethereum#ETFs now!

123•••10•••1718
ПретходнаСтраница 1 од 18Следна