[Python] Using match statement with a class in Python 3

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    Can somebody explain why in the following code Two matches?

    >>> class One:
    ... pass
    ...
    >>> class Two:
    ... pass
    ...
    >>> a = One()
    >>>
    >>> match a.__class__:
    ... case Two:
    ... print("is two")
    ...
    is two
    >>>

    Continue reading...

Compartilhe esta Página