Consider this snippet:
globalVar = 25 def myfunc(paramVar): localVar = 30 print \"Vars: {globalVar}, {paramVar}, {localVar}!\".format(**VARS_IN_SCOP
Interpolation into strings works in the simplest possible way. Just list your variables. Python checks locals and globals for you.
globalVar = 25 def myfunc(paramVar): localVar = 30 print "Vars: %d, %d, %d!" % ( globalVar, paramVar, localVar ) myfunc(123)