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 слични објави

Пребарај: #consider

当前筛选 #consider清除筛选
America 🇺🇸 News & Politics

@America · Post #10234 · 18.12.2025 г., 02:34

😄Consider ➖➖➖➖➖➖ 🔘 The verb, consider can mean spend time to think, or think about something 🔜 I'm going to take some time to consider, then I'll tell you my decision. 🔜I'm considering how we can best use our time. 🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement. 🔜 She's learnt so much, considering how late she started the course. 🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like. 🔜 I consider him to be the best writer of his generation. 🔜 I consider her an expert. She knows so much about history. #Consider👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

😄Consider ➖➖➖➖➖➖ 🔘 The verb, consider can mean spend time to think, or think about something 🔜 I'm going to take some time to consider, then I'll tell you my decision. 🔜I'm considering how we can best use our time. 🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement. 🔜 She's learnt so much, considering how late she started the course. 🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like. 🔜 I consider him to be the best writer of his generation. 🔜 I consider her an expert. She knows so much about history. #Consider👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

😄Consider ➖➖➖➖➖➖ 🔘 The verb, consider can mean spend time to think, or think about something 🔜 I'm going to take some time to consider, then I'll tell you my decision. 🔜I'm considering how we can best use our time. 🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement. 🔜 She's learnt so much, considering how late she started the course. 🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like. 🔜 I consider him to be the best writer of his generation. 🔜 I consider her an expert. She knows so much about history. #Consider👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags