updating local()

Flavio fccoelho at gmail.com
Wed Oct 5 12:33:34 EDT 2005


Hi,

 I heard time and again that you are not _supposed_ to update the
locals dictionary.

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

#
# Extending Local namespace
#

def fun(a=1,b=2,**args):

	print 'locals:',locals()
	locals().update(args)
	print locals()

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


thanks,

Flávio




More information about the Python-list mailing list