Мы уже знаем, что на текущую сессию интерпретатора изменение 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
#Back Stronger And Better.🦾
Getting Back On Track After An Unsuccessful Losing Streak
Did you lose a huge amount of money in Forex trading and want to desperately win your trading losses back? Don't worry! This has happened to many traders before and there are people who have got back on track. Losing a huge fortune may appear to be an indication of the end of your Forex trading career but it doesn't have to be. Treat your previous losing streak as the greatest lesson that you have had and start all over again. The only thing you need to make sure is not to repeat the same mistakes that you have committed before.
Forex trading is a career that requires a good discipline, patience, emotional stability and hard work. When you loose a huge money for the first time, you might have done the trading blunders that new traders often make. If you are aware of those mistakes and ensure not to do them again, then no one can stop you from succeeding in Forex. But always keep in mind that success doesn't come overnight. It takes years and you have to accept this reality.
Below are few guided steps to pull your string back;
• Take a break to ensure that your mind is free from any regrets or other negative emotions, this will make you slowly unburden yourself from the past and give you the necessary courage and confidence to start trading again.
• Review the mistakes you did the last time, including lack of proper training, poor risk management, and poor emotional management. Make a list of beginner's mistakes in Forex and clearly understand how those mistakes can ruin a trading account... Check most of our previous articles for better understanding on some beginners mistakes so you can be properly guided.
• Refresh your knowledge in Forex, do demo trading and back testing for a few days and start with the small account first. Make sure that the account size gives you enough room to take risks, as you must never risk more than 2% of your capital. Once you start winning some trades, you will get a strong confidence.
FxSignals_Gold Team.