[Python] Is there a way to calculate the shadowing level for an arbitrary Python variable?...

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

  1. Stack

    Stack Membro Participativo

    Let's say I've some code that assumes it's meant to operate within some scope A, but actually some variables within that scope "escape" or are shadowed to some other scope B. Detecting this and disallowing it could be instrumental in proving certain properties of your code.

    Does such a tracking exist within the AST? If not, what would you have to change within the distribution (assume CPython, unless you have some specific expertise in another one) to make something like foo.__shadow__ work in the future?

    Continue reading...

Compartilhe esta Página