python-starlark-go
python-starlark-go copied to clipboard
Support struct
It'd be great to have struct
datatype supported. The implementation is in starlark-go
repo, but seems not enabled by default: https://github.com/google/starlark-go/tree/master/starlarkstruct
Conversion to/from Python values can be done either by writing new class, or reusing namedtuple
. With namedtuple
, you have to take care of builtin index()
and count()
methods. Also to check that object is a named tuple, you can check that it's an instance of tuple
and has _fields
:
isinstance(x, tuple) and hasattr(x, '_fields')
Go is not my area of competence, but I could help with Python side of things.