Earlier quoted context omitted.
I feel that Python will be known in the future as the language that caused a generation to have a crippled sense of reasoning about how to design computer programs. It's lack of a normal, standard scoping model alone teaches a very flawed reasoning about computer programs.
It's lack of a normal, standard scoping model alone teaches a very flawed reasoning about computer programs. Scoping in class definitions is weird, yes. But is that your complaint? What's wrong with the scoping model in general?
That for-loops work by assignment rather than creating a new scope, or that if-conditions do not create a new scope for their arms is most unusual.
Not only does it not teach programmers to properly reason about scope, but it results into subtle bugs that are easy to miss. Consider the following:
list = []
for x in iterator:
list.append(lambda y: some_code_that_closes_over(x))
This almost certainly does not behave as the programmer intended, for the for-loop does not create a new scope, so all iterations of the loop share the same scope, and thus every closure that closes over `x` handles the same `x`, which will have the value that `x` had at the last loop, thus effectively mutating the closure after appending it to the list, so that the list will only contain effectively identical closures.The proper way do it is by using the fact that functions do create a scope:
list = []
def loop_function(x):
list.append(lambda y: some_code_that_coses_over(x))
for x in iterator:
loop_function(x)
Certainly code that looks quite hackey to work around the lack of normal, expected block scoping.