Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update snippets to use enums #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

System25
Copy link

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.

@azazel75
Copy link
Collaborator

mmm.. Does JS supports Enums? Do you have a link to some docs?

@System25
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants