[Python] Mapping enum to enum [closed]

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I need to map enum to enum

    class States(Enum):
    INIT = 0
    LISTEN = 1
    HANDSHAKE = 2


    so that I have transitions dictionary from one state to another:

    transitions: Dict[States, States] = {
    States.INIT: States.LISTEN,
    States.LISTEN: States.HANDSHAKE,
    States.HANDSHAKE: States.HANDSHAKE,
    }



    I start with

    state = States.INIT


    but then this never evaluates to true:

    if state in transitions:
    do_this()


    What do I need to correct?

    Continue reading...

Compartilhe esta Página