Make lambdas proper closures

It is a part of what makes it Python. If you cannot live with this, Python is not for you.

first of all, no need for condescending tone, there is no god-given decree that sets in stone what python is and how it has to be. anything can change and a lot has already changed throughout this language’s history.

now on to the relevant stuff:

And even if by some magic allow self-recursive functions, what to do with indirect recursion? You will need a forward declaration of functions, classes, global and local variables, methods, attributes.

you’re reacting to an off-hand comment i made, treating it as if it’s my main contention and suggestion to change it in python. well, quite simply, it’s not.

since we’re on this topic, i can elaborate why i made that comment, but just so we’re clear - i’m ok with how name resolution works in python and absolutely don’t intend to suggest to change it.

HOWEVER

whether the code is interpreted or compiled, usually it passes through AST parser beforehand - right there it’s possible to tell if a name refers to something that hasn’t been or will not be declared in the relevant scope (dynamic declarations aside).

it is an implementation detail of python that functions are callable objects, so you may say that making a distinction between accessing a variable before it’s been created and accessing a function before it’s been defined, is wrong, but IMHO allowing access to an undefined variable leads to more errors than allowing to call an undefined function (provided that interpreter/compiler checks that the name will eventually be defined in relevant scope), which is why i would ban the former and allow the latter.