On Sat, 20 Dec 2008 02:53:16 +0000, MRAB wrote: > If you're sure you want to use the current namespace then: > > for name in namelist: > vars()[name] = func(name, args)
Doesn't work inside a function: >>> def parrot(): ... for name in ['A', 'B', 'C']: ... vars()[name] = ord(name) ... print vars() ... print A ... >>> parrot() {'A': 65, 'C': 67, 'B': 66, 'name': 'C'} Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 5, in parrot NameError: global name 'A' is not defined -- Steven -- http://mail.python.org/mailman/listinfo/python-list