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

Резултати

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

Пребарај: #balemountains

当前筛选 #balemountains清除筛选

🏔️ ETHIOPIA'S NATIONAL PARKS: WHERE NATURE DEFIES LOGIC የኢትዮጵያ ብሔራዊ ፓርኮች፡ ተፈጥሮ ህጎችን የምታፈርስበት Think you know Africa? Think again! 🤯 ━━━━━━━━━━━━━━━━ 🌍 WHEN GEOGRAPHY BREAKS THE RULES Look at this. Tundra? Arctic? Siberia? WRONG!❌ This is 7° NORTH of equator. Not 67°. SEVEN! Sanetti Plateau (ሳኔቲ ፕላቶ) - Bale Mountains National Park Where Ethiopia says "forget your textbooks!" 📚🔥 ━━━━━━━━━━━━━━━━ 🏔️ BALE MOUNTAINS NATIONAL PARK ባሌ ተራሮች ብሔራዊ ፓርክ 📍LOCATION PARADOX: • Latitude: 6°–8° N (equatorial belt!) • Altitude: 3,000–4,377m • Climate: Alpine (like the Alps!) • Temperature: Can freeze! At 7° from equator, you need winter jackets!🧥❄️ ━━━━━━━━━━━━━━━━ 🌿 SANETTI PLATEAU - AFRICA'S SECRET TUNDRA 🏔️HIGHEST PLATEAU IN AFRICA: • Average: 4,000m elevation • Looks like Scandinavia • Heath, moorland, giant lobelias • Sky so close! 🌱GIANT LOBELIAS: • Alien-like plants up to 6m • Only at extreme altitudes • Bloom once, then die "ከምድር ውጭ ይመስላል" (Looks extraterrestrial) ━━━━━━━━━━━━━━━━ 🦌 MOUNTAIN NYALA (የተራራ ኛላ) 🇪🇹FOUND NOWHERE ELSE: • Endemic to Ethiopia • Discovered 1910! • Magnificent spiral horns • Herds up to 50 📍 Gesso grasslands (ጌሴ ሜዳ), 3,000–3,500m Watching them in highland mist = pure magic✨ ━━━━━━━━━━━━━━━━ 🏔️ SIMIEN MOUNTAINS NATIONAL PARK ስሜን ተራሮች ብሔራዊ ፓርክ 🌟UNESCO WORLD HERITAGE 📍"ROOF OF AFRICA": • Ras Dashen: 4,550m (4th highest!) • Escarpments: 1,000m+ sheer drops • Landscapes rival Grand Canyon "መንግሥተ ሰማያት" (Kingdom of Heaven) ━━━━━━━━━━━━━━━━ 🐒 GELADA BABOONS (የሰሜን ዝንጀሮ) ❤️BLEEDING-HEART MONKEYS: • Red chest "bleeding heart" • Only grass-eating monkeys on Earth! • Live 3,000–4,500m • Troops of 300+! 🦍BEHAVIORS: • Graze like sheep • Sleep on cliff faces • 30+ vocalizations Found ONLY in Ethiopian Highlands!🌍 ━━━━━━━━━━━━━━━━ 🐐 WALIA IBEX (ዋልያ) - CLIFF MASTERS 🏔️ENDEMIC TO SIMIEN: • Endangered mountain goat • ~500 remaining • Near-vertical cliff masters • Horns up to 1m Impossible climbs made easy!😱 ━━━━━━━━━━━━━━━━ 🌍 OTHER GEMS 🦒AWASH: Oryx, gazelles, hot springs 🐊OMO: Remote wilderness, elephants 🦩NECHISAR: "White Grass," zebras, kudus ━━━━━━━━━━━━━━━━ 🎒 EXPERIENCE THE WILDERNESS 🏔️BALE: • Trekking "African tundra" • Mountain nyala viewing • Harenna Forest 🏔️SIMIEN: • Multi-day treks • Gelada encounters • Ras Dashen summit • UNESCO photography 📸 Best: Oct–Mar (dry), Jun–Sep (green) ━━━━━━━━━━━━━━━━ 🌟 WHY ETHIOPIA'S PARKS ARE SPECIAL • Highest endemic concentration in Africa • Landscapes found nowhere else • Ancient ecosystems unchanged • Culture + nature combined "ልዩ የሆነ ተፈጥሮ" (Unique nature) ━━━━━━━━━━━━━━━━ 💡 MIND-BLOWING FACTS: 🤯 More endemic mammals than any African country! 🤯 Giant lobelias evolved for equator frosts! 🤯 Geladas' chest changes color with hormones! 🤯 Walia population recovering: 150 → 500! ━━━━━━━━━━━━━━━━ Ethiopia's nature doesn't follow Earth's rules - it creates its own!🌍✨ This is ETHIOPIA.🇪🇹💚💛❤️ ━━━━━━━━━━━━━━━━ 🌍 ETHIOPIA | ЭФИОПИЯ | ኢትዮጵያ 📱@ethiopia telegram #EthiopiaNationalParks#BaleMountains#SimienMountains#MountainNyala#GeladaBaboon#WaliaIbex#UNESCOHeritage#AfricanWildlife

🦊 ETHIOPIAN WOLF: THE LAST 500 ብር ተኵላ፡ የመጨረሻዎቹ 500 Beauty so rare, it hurts to watch. 💔 ━━━━━━━━━━━━━━━━ 💔 THE RAREST CANID ON EARTH ብር ተኵላ (Bir Tekula) - "Silver Wolf" Only 500 individuals left. In the entire world. ALL living ONLY in Ethiopia.🇪🇹 If they disappear from Ethiopia - they disappear FOREVER. ━━━━━━━━━━━━━━━━ 🔥 WHAT MAKES THEM SPECIAL 🎨APPEARANCE: • Red-rust coat shimmering in sun • White chest, long elegant legs • Amber eyes, intelligent gaze • Built for high altitude (3,000-4,500m!) 📍HABITAT: • Afro-alpine meadows • "Tundra at equator" (Sanetti Plateau) • Freezing nights, thin air • Extreme conditions 🎯BEHAVIOR: • Hunts giant mole rats • Diurnal (rare for canids!) • Social packs, monogamous pairs • Cooperative breeding ━━━━━━━━━━━━━━━━ 💪 GRACE IN MOTION Watch the video. 🎬 Slow motion reveals perfection: Every step - calculated Every leap - balletic Every landing - акробат's skill At 4,000m altitude where humans struggle... The Ethiopian Wolf THRIVES. "የተራራዎች ባለቤት" (Master of the mountains) ━━━━━━━━━━━━━━━━ 🇪🇹 WHY THIS MATTERS 💚FOR ETHIOPIA: • Symbol of unique biodiversity • National pride • Ecotourism jobs • Part of identity 🌍FOR THE WORLD: • Irreplaceable genetic heritage • Ecosystem health indicator • Reminder: extinction is forever "ብር ተኵላ የኢትዮጵያ ኩራት ነው" (Ethiopian Wolf is Ethiopia's pride) ━━━━━━━━━━━━━━━━ 😢 THE THREATS ❌ Habitat loss (agriculture expansion) ❌ Disease from domestic dogs (rabies - biggest threat!) ❌ Climate change impacts ❌ Genetic bottleneck (small population) But there is HOPE.💚 ━━━━━━━━━━━━━━━━ 💪 CONSERVATION IN ACTION 🛡️WHAT'S BEING DONE: ✅ Ethiopian Wolf Conservation Programme • Vaccination campaigns • Community education • Research & monitoring ✅ National Parks protection • Ranger patrols • Habitat preservation ✅ Community involvement • Local guardians • Tourism benefits shared ✅ International support • Wildlife organizations • Research partnerships ━━━━━━━━━━━━━━━━ 🌟 WHAT YOU CAN DO 💚SPREAD AWARENESS: Share this post - most don't know they exist! 📸RESPONSIBLE TOURISM: Visit Bale/Simien Mountains Support local ecotourism 💰SUPPORT CONSERVATION: Donate to Ethiopian Wolf Conservation Programme 🗣️SPEAK UP: Rare species need advocates "500 ብቻ። እያንዳንዱ አስፈላጊ ነው።" (Only 500. Each one matters.) ━━━━━━━━━━━━━━━━ 💔 WHICH FUTURE? Your grandchildren ask: "What was an Ethiopian Wolf?" You answer: "They used to run..."😢 OR "They still run free - and WE helped save them!"💪🇪🇹 Which future do YOU choose? ━━━━━━━━━━━━━━━━ 🦊 NOT A STATISTIC 500 beating hearts. 500 graceful hunters. 500 reasons to fight. Ethiopia's gift to the world. The world's responsibility to protect. "ብር ተኵላ - የዓለም ውበት" (Ethiopian Wolf - world's beauty) ━━━━━━━━━━━━━━━━ Watch them run. 🎬 Feel their grace. Understand their rarity. Then ACT.💪 Because 500 is not a lot. But it's enough to save. If we start NOW.⏰ ━━━━━━━━━━━━━━━━ 🌍 ETHIOPIA | ЭФИОПИЯ | ኢትዮጵያ 📱@ethiopia telegram #EthiopianWolf#Save500#CriticallyEndangered#BaleMountains#WildlifeConservation#EthiopiaPride#ProtectNature#EndangeredSpecies