TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #201 · 13 јан.

Мы уже знаем, что на текущую сессию интерпретатора изменение PYTHONPATH никак не повлияет. Но если вы запустите дочерний процесс, то он унаследует окружение текущего процесса, а значит и изменения в любых переменных будут на него влиять. Вот небольшой пример: Объявляем переменную user@host:~$ export PYTHONPATH=/path1 Запускаем интерпретатор user@host:~$ python3 Проверим что в sys.path >>> import sys >>> print(sys.path) ['', '/path1', '/usr/lib/...', ...] Добавляем что-то в переменную >>> import os >>> os.emviron['PYTHONPATH'] = '/path1:/path2' >>> print(sys.path) ['', '/path1', '/usr/lib/...', ...] Изменений нет. Но давайте запустим дочерний процесс и посмотрим там >>> os.system('python3') # теперь мы находимся в другом процессе >>> import sys >>> print(sys.path) ['', '/path1', '/path2', '/usr/lib/...', ...] Тоже самое будет и с subprocess, так как по умолчанию текущее окружение тоже наследуется. >>> import subprocess >>> subprocess.call(['python3', '-c', 'import sys;print(sys.path)']) ['', '/path1', '/path2', '/usr/lib/...', ...] ______________________ Лучшей практикой является передача энвайронмента явно через аргумент env! import subprocess subprocess.call(cmd, env={'PYTHONPATH': '...'}) Это поможет точно понимать какое окружение будет у запускаемого процесса и при этом не изменять окружение текущего процесса. #basic

Hashtags

Резултати

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

Пребарај: #sanders

当前筛选 #sanders清除筛选
Trump's Ear

@trumpsear_tg · Post #1595 · 02.10.2025 г., 20:01

Sen. Bernie Sanders (D-VT) got animated during an interview with CNN's Kaitlan Collins on Tuesday night over President Donald Trump's latest threat to withhold federal funding from New York City. Sanders joined Collins to discuss the looming government shutdown. He expressed concern that the Trump administration could use the shutdown to continue advancing its authoritarian agenda, citing previous examples like firing workers that "they don't like" from the Veterans Administration and making significant cuts to Medicaid. "I'll give you another example, as I'm sure you've heard of it," Sanders told Collins. "I think it was yesterday. Trump says, 'Well, if Mr. [Zohran] Mamdani becomes the mayor of New York City, then I'm going to cut funding from New York City.'" #Trump#Sanders 👂More on Trump's Ear ⚠️

Trump's Ear

@trumpsear_tg · Post #1727 · 03.11.2025 г., 17:59

✊ As Senator Bernie Sanders and Representative Alexandria Ocasio-Cortez joined Zohran Mamdani on Sunday at Forest Hills Stadium, a bigger test for the left may still lie ahead. 🌆📣 #NY#Mamdani#Sanders 👂More on Trump's Ear ⚠️

Libertà è ragione

@libertaeragione · Post #4118 · 12.02.2024 г., 08:37

#USA#Ucraina#Israele#Taiwan Il #Senate ha approvato, con 67 voti favorevoli e 27 contrari, la chiusura dell’accordo per la fornitura di aiuti per un ammontare pari a 95 miliardi di dollari a Ucraina, Israele e Taiwan. Anche 18 senatori repubblicani hanno votato a favore dell’accordo, mentre Bernie #Sanders (#D|Centro-sinistra) è stato l’unico dem ad opporsi alla fornitura di aiuti a tali nazioni. @OsservatorioEsteri