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

Резултати

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

Пребарај: #olympics

当前筛选 #olympics清除筛选
Viral Today

@viral_today · Post #2963 · 02.09.2024 г., 10:30

Amazing close finish in the Paralympic 100m swim! Athletes are classified by functionality, so even with different impairments, like no hands or paralyzed legs, they compete on an even playing field. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2852 · 10.08.2024 г., 12:30

The first-ever Olympic breakdancing tournament is underway in Paris, and it’s already giving us some unforgettable moments. Australian dancer Rachael “Raygun” Gunn went viral for all the wrong reasons—her bizarre moves and headstands left everyone cringing. Gunn lost all three of her matches without scoring a single point. Safe to say, people are now questioning the decision to make breaking an Olympic sport. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2848 · 09.08.2024 г., 12:30

Speed in 1924 vs. 2024: How much faster is today's Olympic gold medalist compared to 100 years ago? The progress might surprise you. Only 0.81 seconds! @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2836 · 07.08.2024 г., 12:30

Italian Olympic gold medalist Thomas Ceccon was spotted sleeping in a park after complaining about the poor conditions at the Olympic Village in Paris. Despite the lack of air conditioning and noisy environment, Ceccon didn’t let it stop him from winning gold in the 100m backstroke. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2815 · 03.08.2024 г., 10:30

Another video from Olympics going viral. The cameraman closely following the athletes jumping on the trampoline throughout the entire event. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2804 · 31.07.2024 г., 17:46

The Egyptian fencer Nada Hafez revealed that she competed in the Olympics' women’s sabre competition — advancing to the round of 16 — while seven months pregnant. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2800 · 30.07.2024 г., 18:10

Bob the Cap Catcher: The First Viral Hero of the Paris Olympics 'Bob the Cap Catcher' became the first viral hero of the Paris Olympics when he jumped into the pool to save a swimmer's lost cap, earning loud cheers from the audience. @Viral_Today / #Olympics

Hashtags

Reza Pahlavi | رضا پهلوی

@officialrezapahlavi · Post #1387 · 08.08.2024 г., 16:40

جمهوری اسلامی قهرمانان ورزش ایران را وادار می‌کند تا وطن‌شان را ترک و بر خلاف میل‌شان زیر پرچم کشورهای دیگر در رقابت‌های بین‌المللی و المپیک شرکت کنند. این رژیم، حتی از رقابت دو ورزشکار ایرانی، دو دوست، که مثل هر رقابت ورزشی دیگری با برد و باخت همراه است، سوءاستفاده سیاسی می‌کند و تلاش می‌کند ایرانی را در مقابل ایرانی قرار دهد. من هم برای ناهید کیانی در رقابت فینال آرزوی پیروزی و کسب مدال طلا را دارم، و هم امیدوارم کیمیا علیزاده در ادامه بتواند مدال باارزش برنزش در المپیک ریو را تکرار کند. اما فارغ از هر نتیجه‌ای، ناهید و کیمیا هر دو برنده این صحنه هستند؛ و بازنده، رژیم پلید و اهریمنی جمهوری اسلامی است. باور دارم روزی دوباره، ورزشکاران ایرانی با افتخار و آزادانه زیر پرچم ملی ایران در مسابقات المپیک شرکت خواهند کرد، و با پشتیبانی یک ملت، برای ایران، افتخار به ارمغان خواهند آورد. The Islamic Republic forces Iran's champions to leave their homeland against their will and compete under the flags of other nations in international competitions like the #Olympics. This regime even attempts political exploitation of the competition between two Iranian athletes, two friends, where, like any other sporting contest, there are winners and losers. Yet the regime nonetheless tries to pit Iranian against Iranian. I wish Nahid Kiyani victory and a gold medal in the final and I also hope Kimiya Alizadeh can replicate her valuable bronze medal from the Rio Olympics. But regardless of the outcome, both Nahid and Kimiya are winners. The loser is the vile and evil Islamic Republic. I know that one day, Iranian athletes will again proudly and freely compete under the national flag of Iran in the Olympics and, with the support of a nation, bring Iran honor. @OfficialRezaPahlavi

Hashtags

FC Bayern English

@FCBayernEN · Post #224353 · 07.02.2026 г., 00:47

FC Bayern (TikTok) ❄️ 𝟮𝟬𝟮𝟲 𝗪𝗶𝗻𝘁𝗲𝗿 𝗢𝗹𝘆𝗺𝗽𝗶𝗰𝘀 🥇🥈🥉 The Allianz Arena shines in the colors of the German and Italian flags at the start of the Olympic Games in Milano Cortina. 🇩🇪🏟️🇮🇹 This is a symbol of solidarity and stands for the unique power of sport to bring people from all nations together. We keep our fingers crossed for all athletes and wish them a peaceful and successful Olympic and Paralympic Games.#Olympics#MilanoCortina2026

ПретходнаСтраница 1 од 3Следна