Мы уже знаем, что на текущую сессию интерпретатора изменение 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
😄Account
➖➖➖➖➖➖
🔘An account is a record. We often use it to talk about recording money. If a bank looks after your money, you have an account with them. The arrangement that a business has with a client can also be called an account.
🔜You should put that money in a saving account.
🔜I'm responsible for the company's biggest account.
🔘An account can also be a description of something that happened, or a story.
🔜The police wanted to hear his account of what happened.
🔘We also use account in some common expressions. If you take something into account, then you consider it and if you account for something you explain why it happened.
🔜You'll need to take many factors into account to make this decision.
🔜We need you to account for your behaviour.
#Account👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys
@creationdatebot
Qué puede hacer este bot?
Este bot interpola las fechas de creación de cuentas basadas en ID de telegrama dado
Idioma: Inglés, Español, Ruso, uzbeco, Polaco, Árabe
(visto en @BotsGram_cu)
#account, #creationdate, #ids
@CheckRestrictionsBot
Qué puede hacer este bot?
Te ayudaré a saber qué restricciones tienen tus bots, grupos o canales.
Idioma: Inglés
(visto en @BotsGram_cu)
#restrict, #restrict, #restriction, #account, #check, #telegram, #private, #channels
@getaltsbot
Qué puede hacer este bot?
Este bot le permite alquilar números reales de teléfono por un período de 20 minutos para registrar cuentas de Telegram, Google, WhatsApp.
Idioma: Inglés
(visto en @BotsGram_cu)
#alt, #account, #phonenumber, #paid, #buy, #identity, #telegram
@pwned_robot
Qué puede hacer este bot?
Telegram Bot que puede comprobar si tiene una cuenta o contraseña que se ha visto comprometida en una violación de datos. Uso limitado (se pagan pocas opciones).
Idioma: Inglés
(visto en @BotsGram_cu)
#breach, #security, #hack, #password, #account, #compromised, #pwned, #checkpsw, #paste, #paid