Script Editor debug executing commented out code

Running Script Editor in Rhino 8.30.26075.13001, 2026-03-16 with Python 3 files. Whilst debugging the initialization of an object Rhino was executing lines of code that are commented out, as shown here:

I’ve tried to reproduce this by typing the same code into new caller and callee files but they behave correctly, so it appears to be file specific.

Possibly something to do with a cached copy of the file from before the code was commented out? Reloading the Python 3 engine fixed the problem, but means I don’t have anything to help you solve the problem…

Edit: Now I have uncommented the two lines and the Script editor is still jumping over them! Back to reloading the engine I guess.

It seems like Rhino doesn’t expect the callee file to be edited. That’s unrealistic.

Weird. Are you sure you just didn’t forget to press save after commenting out that line?

Hi James,

If the file was unsaved you’d see a dot in the tab at the top.

It’s almost certainly a caching issue.

Regards
Jeremy

I think I have found before that python files that are referenced from a library are not updated, does this YouTrack accurately describe your issue @jeremy5?

Hi Callum,

Yes that seems to be the same issue. FTAOD, the files in the library directory get updated and match what is seen in the edit tab when you save, but the calling code does not see the updated code until the python 3 engine is restarted.

I wonder if this is connected: the option to edit the library files is greyed out (reported elsewhere I think) so you can’t get them onto a tab from the project tree - you have to open file and navigate to the folder. Maybe the project is accessing a read only cached copy of the callee and this is reflected in the out of date code?

Let me know if there’s any way I can help you resolve this.

Regards
Jeremy

That is my experience, and that would explain your commented out code running

FWIW, this is standard Python behavior. Imported modules are cached on import and will generally not reload until the Python interpreter is restarted. Rhino does not restart the interpreter every time you execute a script, so your modules appear unaffected by edits (unless you tell Rhino to restart the interpreter).

The standard way to get around this in Python is to use importlib.reload() (imp.reload in Python 2), but be sure to read its documentation and caveats before using it everywhere.

Pierre,

Thanks for explaining this. I wasn’t aware of this impediment to development until I tripped over it. (Maybe this could usefully go prominently into the documentation?) I’ll try the reload option but it may work out better to keep restarting the engine, which isn’t onerous when one knows it is needed.

Regards
Jeremy