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

Резултати

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

Пребарај: #navaloperations

当前筛选 #navaloperations清除筛选
Crypto M - Crypto News

@CryptoM · Post #65150 · 11.04.2026 г., 12:55

🚀 U.S. Navy Ships Navigate Hormuz Strait Without Coordination with Iran On April 11, U.S. officials announced that several U.S. Navy vessels traversed the Strait of Hormuz on Saturday. According to BlockBeats, the passage was conducted without coordination with Iranian authorities. The Strait of Hormuz is a strategic waterway, and such movements often draw international attention due to the geopolitical tensions in the region. #USNavy#HormuzStrait#Iran#Geopolitics#NavalOperations#InternationalRelations#MiddleEast

Crypto M - Crypto News

@CryptoM · Post #65296 · 12.04.2026 г., 15:20

🚀 Iran Intercepts U.S. Warships Near Strait of Hormuz Iran's navy reported intercepting two U.S. warships near the Strait of Hormuz as they attempted to enter the Persian Gulf during a ceasefire. According to NS3.AI, the vessels were identified as the Frank E. Petersen and Michael Murphy. Iran alleged that the ships aimed to project an image of a successful passage and potentially influence ongoing negotiations between the U.S. and Iran. #Iran#USNavy#StraitOfHormuz#Military#NavalOperations#PersianGulf#Geopolitics#InternationalRelations

Crypto M - Crypto News

@CryptoM · Post #65096 · 11.04.2026 г., 00:45

🚀 Iran Faces Challenges in Reopening Hormuz Strait Due to Unlocated Mines Iran is encountering difficulties in fully reopening the Strait of Hormuz as it struggles to locate all the mines it previously deployed. According to Odaily, the country also lacks the necessary capabilities to effectively clear these mines. This situation poses significant challenges for Iran in ensuring the safe passage of vessels through this critical waterway. #Iran#HormuzStrait#Mines#MaritimeSafety#Shipping#NavalOperations#InternationalTrade#Geopolitics

Crypto M - Crypto News

@CryptoM · Post #65313 · 12.04.2026 г., 22:02

🚀 CENTCOM to Enforce Blockade on Iranian Maritime Traffic CENTCOM has announced a blockade on all maritime traffic entering and leaving Iranian ports, effective April 13 at 10 a.m. ET. According to NS3.AI, this directive applies to vessels of any flag or ownership within Iranian coastal waters, including ports in the Arabian Gulf and the Gulf of Oman. Ships transiting the Strait of Hormuz to or from non-Iranian ports will maintain freedom of navigation. CENTCOM has not specified the duration of the blockade and stated that further guidance will be provided. #CENTCOM#Iran#Maritime#Blockade#StraitOfHormuz#ArabianGulf#GulfOfOman#NavalOperations

Crypto M - Crypto News

@CryptoM · Post #65342 · 13.04.2026 г., 00:52

🚀 UK Declines Participation in US Strait of Hormuz Blockade Informed sources have revealed that the United Kingdom will not join the United States in a blockade operation in the Strait of Hormuz, following an announcement by U.S. President Donald Trump that the US Navy would block the waterway. According to NS3.AI, a UK government spokesperson emphasized the country's commitment to freedom of navigation and stated that the UK is collaborating with France and other partners to form a coalition aimed at safeguarding the route. #UK#US#StraitOfHormuz#Blockade#NavalOperations#FreedomOfNavigation#InternationalRelations#Coalition#MaritimeSecurity