**kwds behavior?

Paradox JoeyTaj at netzero.com
Tue Sep 2 10:52:22 EDT 2003


Why does the following attempts to pass in keywords arguments not
work. It would be alot cooler if there was a way to not have to have
the function defined with the variable name. It really seems to me
that the 3rd function should work. Does anyone know how to accomplish
something like this.
def testKeywords1 (**kwds):
	print x
	
def testKeywords2 (**kwds):
	locals().update(kwds)
	print x
		
def testKeywords3 (**kwds):
	locals().update(kwds)
	def testNested():
		print x
	testNested()
	
dict = {}
dict['x'] = 5
# doesn't work
testKeywords1(**dict)
# doesn't work
testKeywords2(**dict)
# doesn't work
testKeywords3(**dict)




More information about the Python-list mailing list