You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Escaped OpenSCAD identifiers don't get exposed (because a single _ makes them private) #17
OpenSCAD allows identifiers which are "illegal" python identifiers. For example $fn, import, [MCAD.]2Dshapes.
The cuurent solution to this problem is that all "illegal" identifiers (either python keywords or starting with $ or a digit) get escaped. The escape mechnism prepends a single underscore (e.g. $fn -> _fn, import -> _import, MCAD._2Dshapes). This makes them "legal" python identifiers and everything seemed to be fine.
Buuuuut..... it turned out that the prepending underscore makes objects private in python and private objects don't get exported / imported by default. The result is, that from solid2 import * does -- for example -- not import _import even though it's there.
Atm if you want to use such a entity you have to explicitly import it:
We need to prepend something (because of for example 2Dshapes) and I don't like to prepend sp_ or similar. Furthermore I don't want to make breaking changes again to fix this issue.
So I'm sorry for this bad decision I made some time ago, but that's life.
if explicit import lists solve the issue, that would mean, that we
would need to create explicit import lists for everything (since the
top level namespace would need it).... that sounds like a lot of
work and book keeping...
Activity
mingmingrr commentedon Nov 9, 2023
What about using an explicit import list? Just include it like
__all__ = ('_import', 'resize', ...)https://docs.python.org/3.12/tutorial/modules.html#importing-from-a-package
jeff-dh commentedon Nov 10, 2023