I understand the logic behind requiring global if a global variable is assigned to within a function,
but I don't understand why this can't be done:
y = 0
def x():
y = y
# Now modify the local version, but not the global one
Calling x results in an UnboundLocalError, even though there's no ambiguity here: The right-hand side of the assignment should be evaluated to the global variable since y is undefined in a local scope when it is executed.
This question is similar to this one (which doesn't have any detailed answers), but is more about the reasoning behind the language design.
I wouldn't write code like that because it is confusing, but I don't see why the language would forbid it. It seems inconsistent with how globals (or for that matter nonlocals) usually behave in python.