Наверняка вы замечали, что в 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
🏆 GuPay Team Cup – 2025 FIFA Club World Cup Edition is LIVE! ⚽️
Choose your team. Power it with every transaction.
From the pitch to the blockchain — this is where Web3 meets real-world passion. ⚽️
🗓 June 9 – July 15, 2025
Support 1 of 32 legendary clubs from the official 2025 FIFA Club World Cup, use GuPay, and help your squad rise to the top!
🎯 How to join:
1️⃣Pick your favorite club by filling out the registration form: link
2️⃣ Make transactions using GuPay throughout the tournament
3️⃣ Each transaction boosts your team’s total score on the leaderboard
🎁 $5,000 Prize Pool
The entire reward will be shared among users who joined the team with the highest total transaction volume via GuPay during the campaign.
📌 Fill the form now to lock in your team choice: link
📊 Team standings and leaderboard will be updated regularly — stay tuned!
🌐 From sport to spending, culture to crypto — Gumart is bringing Web3 to real life, one goal at a time.
#GuPayTeamCup#GuGiveaway
🏆 GuPay Team Cup – FIFA Vibes, $5,000 Prize Pool! 📈
Something big is coming to GuPay... and it’s dressed in jerseys, flags, and fire.✨
⚽️ 32 teams - inspired by the world of FIFA
💥 Fierce competition, full of national pride
💰A massive $5,000 prize pool waiting at the finish line
Choose your team. Make your moves.
Support your side and help them rise to the top.
Can you guess what’s coming? Stay tuned 👀
#GuPayTeamCup#GuGiveaway
🌐 Gumart’s Biggest Global Campaign Ever Is Live – Welcome to Gu Go Global! ✋
This isn’t just another event series - it’s a worldwide Web3 movement.🏅
From the heart of Europe to the soul of Asia, from the energy of the Americas to the innovation of Africa and the heritage of Australia - Gumart is going global, and this time, we’re taking the entire community with us.🎉🏆
And yes, it comes with our biggest giveaway ever.💎
For the first time, users from different continents will unlock exclusive rewards, legendary surprises, and global recognition.📌
This is your chance to represent your region and shine on the world stage. Once-in-a-lifetime perks. 🔼
#GuGlobal#GuGiveaway
Introduce GuEurope: First Giveaway is LIVE! Paris, Here We Come!
We’re giving away 3 VIP Tickets to Paris Blockchain Week - the ultimate Web3 experience in Europe! 🏰
What’s included in the VIP Ticket:
🔼Full access to all main stages & premium sessions
🥳Exclusive networking with top founders, VCs & Web3 leaders
📈Fast-track entry + VIP lounge access
🛍Exclusive VIP Dinner beneath the stunning Pyramide du Louvre.
🏆 How to win?
Climb to the Top 3 of the Europe referral leaderboard during #GuGoGlobal from April 4 to April 8💸
Let’s go, Europe. See you in Paris.
#GuEurope#GuGoGlobal#GuGiveaway
🏆 GuPay Team Cup – The Race Is On! ⚽️
Just 3 days in, and over 2,000 Gumart residents have jumped into the GuPay Team Cup – 2025 FIFA Club World Cup Edition!🚀
🔥 The leaderboard is heating up:
1️⃣ Real Madrid is leading the charge
2️⃣ Chelsea right behind
3️⃣ Manchester City chasing hard!
Want your team to rise? 💥
👉 Every GuPay transaction boosts your team’s score and brings you closer to the $5,000 prize pool!
📍Choose your team now and start transacting: link
#GuPayTeamCup#GuGiveaway#FIFAClubWorldCup