The answer is (almost) never to edit the generated code
When you create an experiment in Builder, PsychoPy then generates a Python file which you can use to run the experiment locally and two JavaScript files suitable for running the experiment online (using current and older browsers).
If something doesn’t work, there may be a temptation to make edits directly to the Python/JavaScript files rather than the Builder file. However, this is generally a bad idea for two reasons:
-
The process is one-way. If you later go back to the Builder file any changes you have made in the generated code will be lost when you generate new Py/JS files.
-
You are more likely to make a mistake and break something. PsychoPy generates the code according to strict rules, which are not the same as ones you might use when writing an experiment in Coder from scratch.
Sometimes bugs are identified in PsychoPy which can be fixed by editing the generated code until the next release ensures that PsychoPy generates the correct code in the first place.
Let this thread be a warning against manual edits:
If you have an example of a manual edit to generated code that you would recommend, please send me a PM and I’ll add it here.