Skip to content

Escaped OpenSCAD identifiers don't get exposed (because a single _ makes them private) #17

Open
@jeff-dh

Description

@jeff-dh

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:

from solid2.core.builtins.builtin_primitives import _import
_import('path/to/my.stl')

I don't have any solution for this issue (yet).

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 anyone has any ideas, let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions