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

Резултати

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

Пребарај: #legaldispute

当前筛选 #legaldispute清除筛选
Hong Kong Democracy Movement

@hkdmovement · Post #6883 · 19.12.2023 г., 22:30

Dec 19: Founder of Apple Daily, Jimmy Lai, and three Apple companies continue their trial on charges of conspiring with foreign forces and publishing seditious publications. Yesterday, the defense argued that the prosecution's addition of sedition charges exceeded the time limit for prosecution. Today, they added that the prosecution should have timely initiated charges due to the six-month limit for sedition offenses. The prosecution contends that the conspiracy was ongoing, citing over 160 seditious publications released by Lai within two years. The judge will rule on the legal dispute this Friday. Legal dispute arises as the six-month time limit for sedition offenses becomes a focal point in the trial of Jimmy Lai and the Apple Daily companies. Defense argues charges exceed the limit, questioning court jurisdiction. Prosecution contends ongoing conspiracy justifies charges. Ruling expected Friday. #JimmyLai#AppleDaily#Trial#LegalDispute#SeditionCharges