Academic Work Personal
|
Python /
locals and globals
def foo(arg): x = 1 print locals() foo('lacus') # {'x': 1, 'arg': 'lacus'} def bar(arg): # called as 'bar(3)' x = 1 print locals() # {'x': 1, 'arg': 3} , i.e. local variables SO FAR y = 3 locals()['x'] = 2 print "x =", x # x = 1 print locals() # {'y': 3, 'x': 1, 'arg': 3} z = 7 print "z =", z # z = 7 bar(3) For dictionary-based string formatting with |
anime | bash | blogs | bsd | c/c++ | c64 | calc | comics | convert | cube | del.icio.us | digg | east | eBooks | egeszseg | elite | firefox | flash | fun | games | gimp | google | groovy | hardware | hit&run | howto | java | javascript | knife | lang | latex | liferay | linux | lovecraft | magyar | maths | movies | music | p2p | perl | pdf | photoshop | php | pmwiki | prog | python | radio | recept | rts | scala | scene | sci-fi | scripting | security | shell | space | súlyos | telephone | torrente | translate | ubuntu | vim | wallpapers | webutils | wikis | windows Blogs and Dev. * Ubuntu Incident Places Debrecen | France | Hungary | Montreal | Nancy Notes Hobby Projects * Jabba's Codes Quick Links [ edit ] |