[Python] Determine if Python variable is an instance of a built-in type

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

  1. Stack

    Stack Membro Participativo

    I need to determine if a given Python variable is an instance of native type: str, int, float, bool, list, dict and so on. Is there elegant way to doing it?

    Or is this the only way:

    if myvar in (str, int, float, bool):
    # do something

    Continue reading...

Compartilhe esta Página