8000 Accessing Enum name by `str()` · Issue #291 · danielgtaylor/python-betterproto · GitHub
[go: up one dir, main page]

Skip to content
Accessing Enum name by str() #291
@GalBezalel-RecoLabs

Description

@GalBezalel-RecoLabs

Say I've compiled:
class Priority(betterproto.Enum):
PRIORITY_LOW = 0
PRIORITY_MEDIUM = 1
PRIORITY_HIGH = 2

Accessing the string value of each instance (which is defined by .toString()) is done similarly to Enum class in python, via Priority.PRIORITY_LOW.name, for example.

From usability point of view, I'd like to access this by the pythonic convention of str(Priority.PRIORITY_LOW). (i.e. add __str__ method to the compiled class).

Appreciate your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0