Namespaces question
Chris Withers
chrisw at nipltd.com
Mon Mar 26 12:16:21 EST 2001
Hi,
I've got a method as follows:
def create(self):
for name in ['x','y','z']:
value = session.get(name,None)
if value is None:
errors.append('No %s supplied.' % name)
else:
locals()[name]=value
if errors:
return errors
print x
...now I know it's not right, 'cos I get a NameError on x at the print
statement.
What should I be using instead of locals()?
cheers,
Chris
More information about the Python-list
mailing list