Why doesn't eval of generator expression work with locals?

James Mills prologic at shortcircuit.net.au
Wed Jan 28 00:51:37 CET 2009

On Wed, Jan 28, 2009 at 9:31 AM, Fabio Zadrozny <fabiofz at gmail.com> wrote:
> Anyone knows why the code below gives an error?
> global_vars = {}
> local_vars = {'ar':["foo", "bar"], 'y':"bar"}
> print eval('all((x == y for x in ar))', global_vars, local_vars)

y is undefined in your generator expression.

Why are you using eval ?


More information about the Python-list mailing list