metapensiero.pj
metapensiero.pj copied to clipboard
Update snippets to use enums
When a class extends enum.Enum you have to define the properties at class level. Also the values need to be an object with "name" and "value" properties.
mmm.. Does JS supports Enums? Do you have a link to some docs?
Hi @azazel75, It is not a matter of having enums in Javascript, it is a matter of supporting Python Enums (https://docs.python.org/3/howto/enum.html).
So I have an Enum in Python like:
from enum import Enum
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
It has to be transformed into something that allows me to use Color.RED in code. So "RED" has to be defined at class level.
The code is transformed into:
class Color extends Enum {
}
_pj.set_properties(Color, {"RED": 1, "GREEN": 2, "BLUE": 3});
So _pj.set_properties has to be aware that this is an enum so "RED", "GREEN" and "BLUE" are defined at class level.
Thanks