Adding Functions to GoPiGo library

Hello I wrote a function in Desktop/GoPiGo/Software/Python/gopigo.py and compiled the file in hopes that it would be available in the gopigo module, but it is not. How can I added functions that will be accessible in the gopigo module (which would allow me to use them in programs that import that module)?

Thanks for your help

Hello,

if I’m understanding properly, you are adding your own functions into the gopigo.py file found in Desktop/GoPiGo/Software/Python ?

I would advise against this, as this file is overwritten each time you do a DI Update Software. You would lose your work. Is there any reason why you want your functions to be in that file, instead of your own file?

if you really, really, really want to do that, and are aware that the functions will disappear if you update the GoPiGo files, then you would have to run

cd /home/pi/Desktop/GoPiGo/Software/Python
python setup.py install

each time you modify the gopigo.py file

Or you can make a copy of the gopigo.py file into the folder where you have your other work. It will pick up the local copy before the library copy (at least I think it will - hmm, worth trying, but I’m pretty certain it does). With this method, you also won’t lose your work if you udpate.

The last suggestion by cleoqc is probably the best here. If you have some custom functions, make a new directory and put the gopigo.py library in it, and the code you’re running with it. This will make them accessible. If you don’t, CleoQc brings up the challenges: you can lose your work with an update, your work won’t be universally accessible outside the directory, etc.

Thank you both. I have tried the last solution (make a new directory and put the gopigo.py library in it, and the code you’re running with it) and it works as expected.