-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support struct #148
Comments
I'd like to have this, too, as I'm moving toward using structs in one of my projects. |
I'm not sure There's also types.SimpleNamespace, which seems to be the closest in spirit to a Starlark struct; My current plan is:
I am planning on implementing this soon, so if this sounds unpalatable to you, please let me know quickly |
Thanks for introducing me to SimpleNamespace. The plan looks good so far. I don't think helper function for dict is important. |
There is a fork with struct support: https://github.com/romain-h/python-starlark-go/tree/build-support-struct It does only work on Python 3.10 and below though due to https://bugs.python.org/issue45482 |
It'd be great to have
struct
datatype supported. The implementation is instarlark-go
repo, but seems not enabled by default: https://github.com/google/starlark-go/tree/master/starlarkstructConversion to/from Python values can be done either by writing new class, or reusing
namedtuple
. Withnamedtuple
, you have to take care of builtinindex()
andcount()
methods. Also to check that object is a named tuple, you can check that it's an instance oftuple
and has_fields
:Go is not my area of competence, but I could help with Python side of things.
The text was updated successfully, but these errors were encountered: