Automatically setting an enum member's value in Python

Python tip:

When the exact value of an enum member is not important, you can use auto() to auto-generate it:

The value starts at 1 and then increases incrementally by 1.

An example👇

from enum import Enum, auto

class Status(Enum):
    DRAFT = auto()
    IN_REVIEW = auto()
    PUBLISHED = auto()
    DELETED = auto()

[<Status.DRAFT: 1>, <Status.IN_REVIEW: 2>, <Status.PUBLISHED: 3>, <Status.DELETED: 4>]