TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #303 · 27 дек.

Наверняка вы замечали, что в Python есть удобная функция для получения переменной окружения os.getenv(NAME) И её "сестра" для создания или изменения переменных окружения os.putenv(NAME, VALUE) Но почему-то putenv() не работает как должно. Энвайромент не обновляется! os.putenv('MYVAR', '1') print(os.getenv('MYVAR')) ... и ничего 😴 Почему так? На самом деле энвайромент обновляется, но это значение не добавляется в словарь os.environ. Откройте исходник функции os.getenv(). Это просто шорткат для os.environ.get() В то время как putenv() это built-in С-функция. Словарь os.environ (или точней класс из MutableMapping) создаётся из энвайромента в момент инициализации. Функция putenv() самостоятельно его не изменяет. В тоже время, когда вы создаёте или изменяете ключ в os.environ, автоматически вызывается putenv() в методе __setitem__(). То есть, технически putenv() всё делает верно, но в os.environ это не отражается. Можно проверить так: >>> os.putenv('MYVAR', '123') >>> os.system('python -c "import os;print(os.getenv(\'MYVAR\'))"') 123 Я объявил переменную в текущем процессе и вызвал дочерний процесс, который её унаследовал и получил в составе os.environ. Аналогично при удалении переменной вызывается еще одна built-in функция unsetenv(), удаляющая переменную из системы. Итого ▫️ Удобней всего явно обновлять переменные через os.environ ▫️ Есть способ неявно создать/удалить переменную через putenv/unsetenv, что не повлияет на os.environ но изменит энвайромент и передаст изменения сабпроцессам. Но так лучше не делать! ▫️os.environ это просто обертка для built-in функций putenv() и unsetenv(). #basic

Hashtags

Резултати

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

Пребарај: #ogcommunity

当前筛选 #ogcommunity清除筛选
MoonPlay

@moonplay_official · Post #40 · 24.06.2024 г., 18:59

New Partnership Announcement: MoonPlay x OGCommunity!🚀 Hey Space Cadets! Kick-starting this week with the announcement of our partnership with👾OGCommunity - a powerhouse in the gaming industry with over 2 million members. They have something for everyone: communication with like-minded people, learning something new, earning money, investing, influencing the development of the industry, developing and launching projects in gaming, taking part in eSports tournaments, and playing the most exciting games. Together, we’re set to elevate your gaming experience to cosmic heights! 🔝 What This PartnershipMeans for You: 👥Enhanced Community: Benefit from the expertise and influence of one of the most impactful communities in gaming. 💸New Opportunities: Discover unique ways to earn, invest, and play, brought to you by the combined efforts of MoonPlay and OGCommunity. ✅Industry Influence: Be part of a movement that shapes the future of gaming, supported by a robust ecosystem of projects and initiatives. Together with OGCommunity, we’re bringing more excitement, innovation, and opportunities to your space adventures. Stay tuned for more updates 👀 as we embark on this stellar journey together! Stellar adventures start here:@moon_land_bot🚀 JOIN OGCOMMUNITY: ✉Channel ❌Twitter 🤖Discord *⃣Linktr.ee🐝Blog🐝OGC App #ToTheMoon#OGCommunity#MoonPlay#partnership#ecosystem#blockchain#gamefi#web3#wenlisting#airdropsoon#communityfirst#taptap#clicker#game

MoonPlay

@moonplay_official · Post #67 · 16.07.2024 г., 17:33

New Mission Pack Alert 👀 OGCommunity, known for building the most influential community and ecosystem in the gaming industry, brings you a fresh pack of missions! Connect with over 2 million members 👥, gain new knowledge, and take part in epic gaming experiences. 👉 Head right to Missions tab and complete special tasks curated by OGCommunity to earn rewards. Don't miss out on this opportunity. Together, we’ll conquer the cosmos and build a thriving lunar colony! 🤩 👉Start your To The Moon adventure now!👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#OGCommunity#ecosystem#blockchain#gamefi#web3#wenlisting#squad#mission#communityfirst#taptap#clicker#game