updating local()

Fredrik Lundh fredrik at pythonware.com
Wed Oct 5 12:48:36 EDT 2005


"Flavio" <fccoelho at gmail.com> wrote:

> Can anyone tell me why, if the following code works, I should not do
> this?

because it doesn't work:

#
# Extending Local namespace, now with Local namespace
#

def fun(a=1,b=2,**args):
    k="K"
    v="V"
    print 'locals:',locals()
    locals().update(args)
    print locals()
    print k
    print v

e = {'s':3,'e':4}
fun(k=10,v=32,**e)


</F> 






More information about the Python-list mailing list