Наверняка вы замечали, что в 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
⚡️TON MemeRepublic: Lambo Week 2 Winner Announced
#TON#LAMBO
TON MemeRepublic reveals the winner of Lambo Week 2 as the LAMBO token, highlighting $100K in liquidity provisioning and $50K in purchases. Utilized through Swap Coffee, this involves DCA engine and liquidity deployment on STON.fi. The process will continue weekly with new tokens.
Source: link
@tonlines
⚡️swap.coffee: $LAMBO Trading Competition Announcement
#LAMBO#swap
swap.coffee presents an exciting $LAMBO trading competition with a prize pool of $2,500. Participants can trade on swap.coffee or @swapi between November 19 and 21. Top traders and random participants have chances to win various prizes in $LAMBO and Lunar Snake Onyx Black gifts.
Source: link
@tonlines
Last Call for Swap.Coffee Trading Competition!
#LAMBO#trading
Swap.coffee is hosting a $LAMBO trading competition with $2,500 in rewards. Less than 2 hours remain to join and trade for a chance to win through various prize categories, including random daily selections and top trading volume rewards.
Source: link
@tonlines
swap.coffee: LAMBO Trading Competition Concludes
#LAMBO#memerepublic
The LAMBO trading competition hosted by swap.coffee has concluded, with all rewards now available in the Claim Center. Congratulations to the LAMBO team for securing 1st place in memerepublic.
Source: link
@tonlines
⚡️TON MemeRepublic: Highlights from Week 2
#BeInCrypto#LAMBO
BeInCrypto has published a comprehensive overview of TON MemeRepublic's second week, highlighting LAMBO's victory with significant community support. The dynamic leaderboard features POK, DICKSHOTI, OC & AMORE, while favorites like UTYA, DOGS, and REDO remain competitive amid new contenders.
Source: link
@tonlines
swap.coffee: Last Chance to Win $LAMBO Prizes
#LAMBO#swap_coffee
Participants have until November 23 to hold their $LAMBO for a chance to win premium prizes on swap.coffee. The trading competition ends tomorrow, providing an opportunity to increase trading volume and earn rewards.
Source: link
@tonlines
⚡️TON MemeRepublic: LAMBO Triumphs in Week 2
#LAMBO#DEX#memecoins
TON MemeRepublic announces LAMBO as the winner of Week 2, awarding $100K after outstanding performance. Updates include a minimum 1% LP trading fee requirement and disqualification for unfounded accusations. Winners are supported with partnerships and guidance to scale their projects.
Source: link
@tonlines
📍 List of abbreviations commonly used in cryptocurrency trading:
#ALTCOIN = Alternate cryptocurrency except bitcoin
#SHITCOIN = A coin with no potential value or use
#BEAR | #BEARISH = Negative price movement
#BULL | #BULLISH = Positive price movement
#LONG = Margin buy position
#SHORT = Margin sell position
#BTFD = Buy The Fucking Dip
#DILDO = Long green or red candles 😆
#DYOR = Do Your Own Research
#FA = Fundamental Analysis
#TA = Technical Analysis
#FOMO = Fear Of Missing Out
#JOMO = Joy Of Missing Out
#FUD = Fear Uncertainty & Doubt
#HODL = Hold a position
#MCAP = Market Capitalization
#MOON = Continuous upward movement of price
#OTC = Over The Counter
#PUMP = Upward price movement
#DUMP = To sell off a coin
#REKT = When you have a bad loss
#WHALE = Very wealthy trader/Market mover
#AMA = Ask me anything
#ATH = All Time High
#ATL = All Time Low
#DLT = Distributed ledger technology
#IMO = In My Opinion
#LAMBO = Lambo is symbol that becomes an elusive goal for most investors
#NOOB = A person who is inexperienced
#SAFU = Secure Asset Funds for Users
#SHILL = Holder of altcoin who just wants to promote it for his own benefit
✅@ElfCryptoVIP