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
solid2.extensions.bosl2 collides with python builtins #45
On Fri, 29 Sep 2023 12:33:54 -0700 taliesin ***@***.***> wrote:
```
from solid2.extension.bosl2 import *
s = sum([1, 2, 3])
print(type(s))
```
outputs <class 'solid2.extensions.bosl2.math.sum'>
One can workaround
```
import solid2.extension.bosl2 as b2
```
but this is pretty inconvenient.
The bosl2.math functions could check if the passed type is of their
concern and forward to the standard functions otherwise?!
so it's all, slice, complex, list, sum, any and format
Up until now, I think we need to rething importing bosl2 (and maybe solid2 itself). Your "workaround" might be the solution.
Another solution would be to explicitly import every single entity used from bosl2:
fromsolid2.extensions.bosl2importcuboid
This seems inpractically but using a lsp this could also be feasible.
All these parts of the library sound to me kind of useless in Solidpython anyway, but I'm not sure..... anyway they could be imported explicitly if needed....
I think it's probably the best way to import 'as', otherwise you'll end up hunting symbols when bosl2 progresses.
Some things are a bit opaque though, as there is a openscad cylinder and a bosl2 cylinder, the latter understanding keywords like anchor.
Probably the solidpython examples should be rewritten avoiding the 'from ... import *' style. This will prevent beginners from stumbling over these kinds of errors. They are not easily tracked for python beginners.
Nice work, if the list of imports gets too long, the alternative import solid2.extensions.bosl2 as b2
is acceptable as well and pretty much inline with numpy as np, for instance.
I'm still not happy with the collision of the bosl2 namespace and globals()... I'm still thinking about striping the critical parts from the bosl2 extension. So reopen.....
Activity
jeff-dh commentedon Sep 30, 2023
taliesin commentedon Oct 1, 2023
BTW 'list' is also hit, where type checking probably won't work.
jeff-dh commentedon Oct 1, 2023
so it's
all, slice, complex, list, sum, anyandformatUp until now, I think we need to rething importing
bosl2(and maybesolid2itself). Your "workaround" might be the solution.Another solution would be to explicitly import every single entity used from bosl2:
This seems inpractically but using a lsp this could also be feasible.
jeff-dh commentedon Oct 1, 2023
Another solution would be to strip the bosl2 extension:
All these parts of the library sound to me kind of useless in Solidpython anyway, but I'm not sure..... anyway they could be imported explicitly if needed....
taliesin commentedon Oct 5, 2023
I think it's probably the best way to import 'as', otherwise you'll end up hunting symbols when bosl2 progresses.
Some things are a bit opaque though, as there is a openscad cylinder and a bosl2 cylinder, the latter understanding keywords like anchor.
Probably the solidpython examples should be rewritten avoiding the 'from ... import *' style. This will prevent beginners from stumbling over these kinds of errors. They are not easily tracked for python beginners.
use explicit imports in examples (#44 #45)
taliesin commentedon Oct 6, 2023
Nice work, if the list of imports gets too long, the alternative
import solid2.extensions.bosl2 as b2is acceptable as well and pretty much inline with numpy as np, for instance.
Thx for the work.
jeff-dh commentedon Oct 6, 2023
https://github.com/jeff-dh/SolidPython/wiki/Importing-SolidPython
#46
jeff-dh commentedon Oct 6, 2023
Hmmm, that was to fast ;)
I'm still not happy with the collision of the bosl2 namespace and
globals()... I'm still thinking about striping the critical parts from the bosl2 extension. So reopen.....jeff-dh commentedon Oct 15, 2023
I striped the math, lists, strings and utility modules from bosl2.std.
This will be published in a 2.1.0 version with some other backwards compatibility breaking changes.