HOME - Recent Changes - Search:

Academic Work


Personal

* pot de départ


dblp


(:twitter:)

-----

[ edit | logout ]
[ help | sandbox | passwd ]

locals and globals

#############################

  • locals returns a copy of the local namespace, i.e. locals is read-only
  • globals returns the actual global namespace, so through globals you can change the global variables
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 locals, see 20091017sprintf.

Cloud City


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
* Python Adventures
* me @ GitHub


Places

Debrecen | France | Hungary | Montreal | Nancy


Notes

full circle | km


Hobby Projects

* Jabba's Codes
* PmWiki
* Firefox
* PHP
* JavaScript
* Scriptorium
* Tutorials
* me @ GitHub


Quick Links


[ edit ]

View - Edit - History - Attach - Print *** Report - Recent Changes - Search
Page last modified on 2009 November 15, 04:31