Is there any way for a python project to use multiple files? I’m fine if it’s a hacky workaround, but I’ve tried and I can’t find out how.
thanks.
Then why did you answer, it has no relevance to the question.
We do not support multi file Python projects in either VEXcode or the VEX VSCode extension, the brain is not able to handle that, however, it’s possible to import modules from the SD Card although I really would not recommend it for a competition robot (due to the fact that if the SD Card is dislodged your code may not run when needed ).
See this old topic that has an example.
Oops
I thought he was talking about how to save a python project as multiple files…
Anyways, thanks for correcting me! (I’ll delete the post)
thanks, do you know is there is a tool to combine separate python files all into one so it can be uploaded to the robot, also do you have any future plans for multi-file support
Update
I was able to write a script to package a folder of Python files into one for use on the robot.
It takes the files in your ./src/
directory and adds code to your main file to write them to an SDCard before your code runs
limitations
- You need a SDCard, as before your code runs, it writes the files you would use to the SDCard
- You can only be 1 directory deep, as the SDCard API does not support making directories, and I don’t feel like adding the logic for that
- you can have as many files in ./src/ (where your main file is), but you cannot have any subdirectories
- I can’t make any promises on the reliability of the packaged code
Please let me know if you would be interested in this, and I can send you the code
I’m currently working on a project that would benefit greatly from the capability of using multiple python files. Unfortunately we can’t switch to C++, but your script using the SDCard sounds like it would work. Could you send me the code so I can take a look? Thank You.
Sounds like a really helpful project, could you please send me the code as well?
shoot, forgot about this. turns out files on the sd card can not create certain classes (motor groups, drivetrains?) and a few others. i just ended up using c++. let me know if you still want the code and ill dig it out
Yes, I’m still interested. By certain classes, do you mean Vex library classes/objects? Thanks.
Yea, that is what i mean. Ill link the code when i have a chance
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.