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

Пребарај: #plantatree

当前筛选 #plantatree清除筛选
Go! Announcements

@gorwachain_announcements · Post #226 · 24.10.2023 г., 17:08

🌱 Going Green: Planting Trees and Promoting Sustainable Living in the Go! Game 🌍🌳 Hello Go! Community, We're excited to share our latest eco-friendly initiative within the Go! Game: The "Plant a Tree" Quest! 🌱🚶‍♂️ 🌿 How It Works 🌿: For every 25,000 steps you complete, the Go! Project will plant a real tree in partnership with organizations dedicated to reforestation and sustainable living. 🌳 It's a fantastic way to make your wellness journey even more impactful! 🌿 Why This Matters 🌿: Environmental Impact: Together, we're reducing our carbon footprint and contributing to a healthier planet. Motivation: Planting a tree adds an extra layer of motivation to hit your step goals. Real-World Impact: Beyond personal wellness, you're making a real, tangible difference in the world. 🌿 How to Join 🌿: ➡️ Open the Go! app and make sure your step tracker is connected. ➡️ Sync your step tracker and start walking! ➡️ For every 25,000 steps, you'll be notified of the tree planted in your name. Are you ready to step up your wellness journey while contributing to a greener, healthier Earth? 🌏👣 Join on https://chat.goplatform.io now! 🌍🌱 #PlantATree#SustainableLiving#EcoFriendly🚶‍♀️🌳