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

Резултати

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

Пребарај: #realtalk

当前筛选 #realtalk清除筛选
Quiet World 🍁

@QuietWorld · Post #6383 · 19.04.2019 г., 14:58

this 💯👌 if you want to apologize, just say sorry and mean it. no need to add anything to make the other person feel bad for being frustated when you are the one who hurt them. #realtalk#quotes@quietworld🍃

Quiet World 🍁

@QuietWorld · Post #7073 · 14.12.2019 г., 07:06

older than us, we were 22 when we were having this conversation), and two of my most observant friends talk about the self-conflict each of our coursemates had as they enter 21. & I wouldn't notice the 'pattern' if my friends didn't point out. & suddenly one of my friends started sharing his moment of depression and how he coped with it. & somehow at that moment I felt like my friends actually noticed my changed behaviour and suspected that there's something bothering my mind and they were actually trying to help me out by asking me out, being with me, spending time with me. & I'm glad that they are wise to not help me out by asking me what's wrong because if they ask me what's wrong , I don't even know what is wrong with me and me realizing that there's something off with me and not knowing what it is gonna make me feel so much wrong 😂 and I'm glad they didn't ask me that question. Instead, they just help me out by being there. I'm so grateful and blessed to have friends like them. I was grateful and I am more grateful now, because I just realized that there's actually so much more blessings I had that I haven't notice more in details until now. :') Anyway this is such a long post I didn't even have any idea that it was gonna be this long I wondered if anyone would even read it from beginning till the end, so here's a quick question, did I managed to keep you engaged from the beginning to the end of this post? 😅 #thoughts#afterthoughts#realtalk#poll @quietworld🍃

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