Editing python scripts on-line?

70 views Asked by At

I'm doing a little bit strange practice for editing the python script that runs on my lab. I just want to know whether what I'm doing is okay and also learn other better practices to do this sort of thing. I have three computers in my lab running a python script to carry out a psychological test and store the participants data. To sync the whole data we collect, we run the python script on a shared Dropbox folder in three computers. The research assistants in the lab do the tests ,approximately two or three tests per hour, and I watch the data or edit the script at home! Because I don't want my editing to bother with running tests I'm doing this trick:

Anytime I edit the script I compile it into the pyc file and the computers in the lab only run the compiled script (.pyc). I've checked that even if I delete or rename the running pyc file, it cause no harm to the testing, so I think this practice ensures that I can edit my script and compile it at anytime and the next test(s) will be run with the new version seamlessly.

I appreciate if I know your thoughts about this.

compilation:

python -m myscript.py

running:

python myscript.pyc
2

There are 2 answers

3
Kevin On

You should place the scripts under version control. This makes it easier to see exactly which version a given participant was using, and to ensure you only roll out versions you're pleased with.

0
Hack Saw On

Perfectly legitimate. It can also help to avoid weird date problems if the editing machine is not time sync'ed up with the test machine. Admittedly this isn't a common problem these days, but I have been bitten by it: I update the .py, but the compiler runs the pyc because I edited on my local machine, and pushed it out to the test machine, and it's time is earlier than the pyc, so the pyc doesn't get recompiled.

Explicitly recompiling it, and pushing that out prevents this.

Also, it discourages people tweaking the file.