globals() and locals() : Variable Scope : Function PYTHON TUTORIALS


PYTHON TUTORIALS » Function » Variable Scope »

 

globals() and locals()


def foo():
    print 'ncalling foo()...'
    aString = 'bar'
    anInt = 42
    print "foo()'s globals:", globals().keys()
    print "foo()'s locals:", locals().keys()

print "__main__'s globals:", globals().keys()
print "__main__'s locals:", locals().keys()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Function
» Variable Scope