Importing VEX Code From Other Files with Python

So I have two separate .v5python files; one for driver control and one for autonomous. I then have a third .v5python file for competitions so I can set it up for competition switches. Instead of copying the code from both files, I want to instead import the code from those files into the main file so I only have to update the code in one place to update it in all. I’ve experimented with all types of importing techniques, using sd cards, and can’t seem to get it to work. Does anyone know anything to help?

If it helps I use my school Chrome Book which is on Chrome OS 96 and use the VEXcode V5 programming software.

I am on Chrome OS 97 now, not that it really makes a difference

Although this doesn’t fix your problem the way you would like, I would recommend looking into the VEXnet competition switch. It allows you to switch between your driver and autonomous code as if it was an actual match. This means you could work in the one file and just use the switch when you want to switch between the two.

2 Likes

There’s an example of how to import a module from the SD Card here.

but, to be honest, for you application I would recommend against doing this

3 Likes

A good old hard drive

Sorry if I wasn’t clear enough. I already use the competition switch for the main program, but wanted to import the code into the main program instead of copying and pasting, so I only have to update the code in one place.

Okay, thanks. I saw that post and used to try and use sd cards, but I couldn’t get it to work. I’ll mess around with it more and if I still can’t get it to work I’ll give up and just revert to copy and pasting all of my code.