r/OpenPythonSCAD • u/WillAdams • Oct 21 '24
Developing (and loading) Python libraries using OpenPythonSCAD
Working on this, and figured it would be good to share what I have learned (and to correct anything which I misunderstood).
2
Upvotes
View all comments
Show parent comment
2
u/gadget3D Oct 22 '24
Python will see exactly those python files, which are included in the path variable.
you can observe the path with
print(sys.path)
I believe, that sys.modules is corresponding to the cache pyc files which python has. if sys.modules does not have such an entry, its not cached at the time.
you can write more simple as:
if 'gcodepreview' in sys.modules:
del sys.modules['gcodepreview']
You will not risk an exception that way