Вопросы про переменную PYTHONPATH
🔸 Как она определяет пути поиска модулей при импорте?
Пути поиска модулей находятся в списке sys.path. Как формируется этот список?
Исходя из документации мы может выделить 3 основных этапа.
▫️Путь к запускаемому скрипту или рабочая директория
▫️ Переменная PYTHONPATH
▫️ Стандартные пути к библиотекам
Это значит, что все три этапа выполняются в момент инициализации интерпретатора. Результат заполняет список sys.path. В том числе и пути, указанные в переменной PYTHONPATH.
🔸 Можно ли добавлять новые пути в эту переменную в Python-коде?
Можно, но учитывая, что используется она только во время старта интерпретатора, никакого эффекта это иметь не будет.
Для изменения путей поиска модулей в коде нужно изменять непосредственно список sys.path.
🔸 Можно ли указать много путей для поиска?
Да, с помощью переменной PYTHONPATH можно указать несколько директорий, разделённых символом разделения пути. Для Linux это символ ":", для Windows это ";".
Например:
export PYTHONPATH=/mnt/libs:~/mylibs
#basic#tricks
The international community has failed people in #Gaza. Humanity has failed. But every day brings new opportunities to change course, and stop the killing. The only lesson we can take is to redouble efforts to pressure for a #ceasefireNOW
https://t.me/claredalymep/275
🔴 Gaza's smallest refugee camp pounded by Israeli airstrikes. Palestinians digging up bodies of loved ones under rubble. Over 90 killed, including children and displaced families. Entire residential blocks wiped out. Camp housing estimated 100,000 people. No warnings given. No aid, fuel, or excavators. Need ceasefire! Arab world, stand with us! #GazaUnderAttack#CeasefireNow
https://www.aljazeera.com/features/2023/12/28/piles-of-body-parts-gazas-maghazi-residents-find-families-in-pieces
Subscribe to @BadVolfNews
🚨 Urgent Call for Ceasefire in Gaza 🚨
USAID staff demand immediate end to violence, decrying civilian deaths and violations of international law. Aid efforts futile amidst indiscriminate bombing. Gaza needs more than just aid, it needs the bombs to stop. Pressure mounts on US government to take action, hold all parties accountable. UN warns of grave risk of genocide. Meanwhile, US continues unwavering support for Israel, providing billions in military aid. Will Congress break the silence? #CeasefireNow#GazaCrisis
https://www.aljazeera.com/news/2023/11/8/more-than-1000-usaid-employees-sign-letter-backing-gaza-ceasefire
Subscribe to @BadVolfNews
Protests swept over Tel Aviv as almost 300,000 people took to the streets to call for bringing back hostages, with no mention of a ceasefire.
#Gaza#Ceasefire#CeasefireNow#Palestine
A bereaved mother mourns her child, as another one of her children is brought in, killed by an Israeli airstrike.
#Gaza#Palestine#Ceasefire#CeasefireNow