[Python] How can one create new scopes in python

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

  1. Stack

    Stack Membro Participativo

    In many languages (and places) there is a nice practice of creating local scopes by creating a block like this.

    void foo()
    {
    ... Do some stuff ...

    if(TRUE)
    {
    char a;
    int b;

    ... Do some more stuff ...
    }

    ... Do even more stuff ...
    }


    How can I implement this in python without getting the unexpected indent error and without using some sort of if True: tricks

    Continue reading...

Compartilhe esta Página