@mygovcoronanewsdesk · Post #12206 · 01.03.2023 г., 07:15
#Budget2023#UrbanPlanning
Hashtags
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
Пребарај: #urbanplanning
@mygovcoronanewsdesk · Post #12206 · 01.03.2023 г., 07:15
#Budget2023#UrbanPlanning
Hashtags
@interesting_planet_facts · Post #1266 · 01.02.2026 г., 12:11
🌎 The ancient city of Mohenjo-daro in present-day Pakistan was part of the Indus Valley Civilization around 2500 BCE. It featured grid-planned streets, advanced drainage, brick houses, and a massive central bath. Mohenjo-daro was mysteriously abandoned by about 1900 BCE without clear evidence of war or disaster. ✨ #archaeology⚡#IndusValley⚡#urbanplanning 👉subscribe Interesting Planet 👉more Channels
@amazingeo · Post #552 · 02.01.2026 г., 20:31
🌍 Paris is creating "urban forests" by planting patches of dense woodland in city plazas and streets. These mini-forests lower summer temperatures and boost urban biodiversity. ✨ #urbanplanning⚡#sustainability⚡#biodiversity⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@mygovcoronanewsdesk · Post #12208 · 01.03.2023 г., 09:20
भारत में अर्बन डेवलेपमेंट के दो प्रमुख पक्ष है- नए शहरों का विकास और पुराने शहरों में पुरानी व्यवस्थाओं का आधुनिकीकरणः प्रधानमंत्री #urbanplanning#budget2023#unionbudget2023 https://youtu.be/CEiyK3D4O-k
@amazingeo · Post #594 · 26.01.2026 г., 12:31
🌍 In Stockholm, almost every resident lives within 300 meters of green space thanks to city planning that weaves parks and nature into neighborhoods—boosting health and local biodiversity. ✨ #urbanplanning⚡#sustainability⚡#cities⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #138 · 29.08.2025 г., 13:12
🌍 Curitiba, Brazil transformed bus transit by designing special lanes just for buses, boosting speed and cutting traffic. This inspired cities worldwide to rethink sustainable urban transport. ✨ #urbanplanning⚡#sustainability⚡#transport⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍
@amazingeo · Post #406 · 23.10.2025 г., 12:31
🌍 Copenhagen aims to become the world’s first carbon-neutral capital by 2025, using bike highways, wind energy, and smart urban drainage to cut emissions while keeping the city livable. ✨ #urbanplanning⚡#sustainability⚡#environment⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #482 · 28.11.2025 г., 20:31
🌍 Singapore’s “park connector” network links a growing web of green trails and corridors across the city, letting wildlife and people travel between parks, even in dense urban neighborhoods. ✨ #urbanplanning⚡#sustainability⚡#wildlife⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #631 · 14.02.2026 г., 12:31
🌍 Some cities recycle wastewater to irrigate parks, saving drinking water for people. This system helps lower water use and keeps urban landscapes greener even in dry climates. ✨ #urbanplanning⚡#sustainability⚡#water⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #291 · 24.09.2025 г., 15:31
🌍 In Freiburg, Germany, whole neighborhoods are designed with solar panels, car-free streets, and green spaces. These urban plans cut energy use and make city life healthier and more sustainable. ✨ #urbanplanning⚡#sustainability⚡#energy⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels
@amazingeo · Post #250 · 17.09.2025 г., 00:12
🌍 Singapore manages stormwater with a vast network of rooftop gardens, ponds, and clever drainage, helping prevent floods while cooling the city and supporting urban wildlife. ✨ #urbanplanning⚡#sustainability⚡#Singapore⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍
@mappasaurusofficial · Post #298 · 06.04.2025 г., 15:13
🍀Build Sustainable Cities with Mappasaurus!🌐 🪄Empower Eco-Friendly Urban Planning: ⏺Optimize Resources: Utilize our maps for efficient resource allocation and green urban projects. ⏺Smart Routing: Reduce emissions with AI-driven routes that minimize travel times and fuel usage. 🦖Why MappaSaurus❓ ⏺Enhance Urban Resilience: Support sustainable development that adapts to environmental challenges. ⏺Encourage Community Involvement: Use transparent mapping to foster public participation in urban planning. ⚔️Shape Greener, Smarter Cities with Us ⏺ See how Mappasaurus leads the way in eco-friendly urban planning. 💯#Mappasaurus#SustainableCities#UrbanPlanning#EcoFriendly#SmartCities