[Python] What does Python do with incorrect type hinting in global scope? [duplicate]

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I found here strange Python code, something like:

    myvar: "Some string"


    I checked it in IPython and it works. But what does it actually do?

    In [16]: myvar: "Some string"

    In [17]: myvar
    ---------------------------------------------------------------------------
    NameError Traceback (most recent call last)
    Cell In[17], line 1
    ----> 1 myvar

    NameError: name 'myvar' is not defined

    Continue reading...

Compartilhe esta Página