Hi,
just today my Python scripts started to do some strange thing.
When I run some script for the first time after restarting Rhino, it runs just fine. But when I change something in the script and try to run it again, it seems that it doesn’t take into account any changes.
I started playing with classes today, but I’m not using them in the scripts where I got these problems.
Maybe it could be problem with the namespaces?
I think you mean that imported scripts are not reloaded after you change them. Is it so? If it is, there’s one reason. To speed things up, the interpreter just parses imports the first time, and then uses the previously-generated code to run the module again.
Luckily, you can use Python’s reload() function to fix this. Remember to remove that function in your final script, so that the code will not have to be regenerated every time.
Hi Giulio,
great, thanks! That was the problem. Or at least when I now use the reload() function, it works as expected.
But still, it’s quite strange to me, because earlier I changed things in modules, that were imported and it worked just fine (at least what I can remember).
This is part of Python. It’s not something that the Rhino editor can influence.
Maybe there was something forcing reload, but I would not know what that could be, sorry.
For sure, if you use the “Reset script engine” from the menu, this will be reloaded. But it’s not the best way, as destroying the engine has lots of consequences for the whole environment.
–
Giulio Piacentino
for Robert McNeel & Associates giulio@mcneel.com