I was surprised today to find out that the following appears to be valid code in Python:
def foo(n):
foo = n * 10
return foo
foo(5)
What in Python allows for a variable name to match the name of the function it is in? Is it just some kind of scoping rule that helps to keep these 2 things separate? so Python simply considers a program's function namespace to be a completely separate animal from the program's variable name space?
(Note: I would hate to do this in my own programs as it's a tad confusing but c'est la vie as they say in France.)