Bruno Bruno - 2 months ago 8x
Python Question

central path for python modules

I am starting to convert a lot of C stuff in python 3.

In C I defined a directory called "Toolbox", where i put all my functions i needed in different programs, so called libraries.

To use a specific library i had just to add the line

#include "/home/User/Toolbox/VectorFunctions.h"

into my source. So i was able to use the same library in different sources.

In python i tried to write some Toolbox functions and implement them into the source with import VectorFunctions, which works, as long as the file is in the same directory as the source.

I there a way (I think there must be one...) telling python that is located in a different directory, e.g. /home/User/Python_Toolbox?

Thanks for any comment!


You can use python path. Writing this code beginning of your program :

import sys

If you have in this folder you can import it :

import VectorFunctions