Is there any way in Python to forbid the use of global variables inside a function?
For example can this:
def some_function():
print(foo)
foo = 'bar'
some_function()
instead of printing bar
be made to raise a NameError
like:
NameError: name 'foo' is not defined
Can you limit the variable scope to that of the function (the inner) and deem the global unreachable?
Could some kind of decorator or something similar be utilized?