Code objects tell you which names are global and which are local:
def foo():
bar = 1
baz = 2
print(bar, baz, qux)
print(foo.__code__.co_names)
print(foo.__code__.co_varnames)
('print', 'qux')
('bar', 'baz')
Ideally, this would be an IPython extension that you enable once and then it continuously warns you whenever you create a function that refers to (non-module, non-callable -- by default, but customizable) globals.
Code objects tell you which names are global and which are local:
Ideally, this would be an IPython extension that you enable once and then it continuously warns you whenever you create a function that refers to (non-module, non-callable -- by default, but customizable) globals.