Considering this snippet:
globalvar = 1
def f():
print globalvar
f()
why doesn't Python throw an exception like it would with the following two snippets?
(This one throws an exception)
globalvar = 1
def f():
globalvar = 2
f()
And this one does too:
another_globalvar = 1
def f():
print globalvar
f()
In other words, why doesn't Python enforce declaring globals for reading, like it does for "locals"?