In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote:
> rafi wrote: > > Reinhold Birkenfeld wrote: > > > > > >>>> exec(eval("'a%s=%s' % (count, value)")) > >>> > >>>why using the eval? > >>> > >>>exec ('a%s=%s' % (count, value)) > >>> > >>>should be fine > >> > >>And this demonstrates why exec as a statement was a mistake ;) > >> > >>It actually is > >> > >>exec 'a%s=%s' % (count, value) > > > > > > Noted. > > > > In the meantime another question I cannot find an answer to: any idea > > why does eval() consider '=' as a syntax error? > > > > >>> eval ('a=1') > > Traceback (most recent call last): > > File "<stdin>", line 1, in ? > > File "<string>", line 1 > > a=1 > > ^ > > SyntaxError: invalid syntax > > > > Thanks > > > Because eval() takes an expression as an argument, and assignment is a > statement. And if you find this distinction annoying, try Lisp. rg -- http://mail.python.org/mailman/listinfo/python-list