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

Резултати

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

Пребарај: #mobilegames

当前筛选 #mobilegames清除筛选
🦅 [ perspective ix ]

@perspectiveix · Post #2040 · 05.10.2020 г., 10:25

🎮Mobile Games in Q3 2020 First-time installs of mobile games climbed nearly 28 percent Y/Y last quarter to 14.2 billion across the #AppStore and #GooglePlay globally. The majority of installs came from Google Play, which grew 36.8% from 8.7 billion in 3Q19 to 11.9 billion. Conversely, the App Store actually saw game installs decline slightly Y/Y, decreasing 4.2% from 2.4 billion in the previous year to 2.3 billion in 3Q20. This figure reflects a decrease in mobile game installs from China’s App Store; outside of China, first-time game installs were up slightly. InnerSloth’s #AmongUs was a breakaway hit, reaching No. 1 among the top-downloaded games of 3Q20 with installs that were more than 13 times what it saw in 3Q19. Read more on SensorTower. #MobileGames 🦅@perspectiveix

ДжекМа Позвонит

@jackmawillcall · Post #86 · 10.03.2020 г., 04:06

ByteDance, the company behind TikTok, has received its first game license. In China, games have to be approved first by the Chinese State Administration of Press, Publication, Radio, Film, and Television (SAPRFT) before being released to the public. In March, 51 games including Warrior Girl Parkour have gained licenses as part of the fifth and latest batch of games of approved games by the authorities (c) KrAsia #china#tiktok#bytedance#mobilegames#chinanews

Bounty Hunters 💎

@trustedairdropsss · Post #655 · 01.03.2021 г., 06:12

Unlock unlimited fun & winning at Rummy24. Download the App Now👉https://rummy24.sng.link/Averc/fcz2/lcft . . . #Rummy24#RummyApp#PlayRummy#UnlimitedFun#PlayRummy#onlinerummy#cardsgame#mobilegames#mobilegaming#mobilegame#cardgames#onlinegame#play#skills#win

Venture Village Wall 🦄

@venturevillagewall · Post #3601 · 20.12.2024 г., 16:16

Weekend Reading for Entrepreneurs Explore this week's top news: 1️⃣ Research on mobile game success probability - Read more2️⃣ Tech trends for 2025 according to Andreessen Horowitz - Find out more3️⃣ Video on David Lieb, creator of Google Photos - Watch here4️⃣ Podcast with Vlad Tenev from Robinhood - Listen in5️⃣ David Kahn's AI predictions for 2025 - Read the article6️⃣ Interview with Rocket Lab CEO Peter Beck - Explore the interview7️⃣ Turning mistakes into success with Flamp.io - Learn how #MobileGames#TechTrends#GooglePhotos#Podcast#AI#RocketLab#StartupSuccess#Sequoia#AndreessenHorowitz#VladTenev#DavidLieb#DavidKahn#PeterBeck#Flamp#YCombinator#SpaceX#Entrepreneurship#Innovation#Research#Investment#Finance