Is this a contradiction in the docs ?

Fuzzyman fuzzyman at gmail.com
Wed Feb 2 09:19:14 EST 2005


Pierre Barbier de Reuille wrote:
> Fuzzyman a écrit :
> >
> >
> > Yes.. but that would mean that eval could only run code objects
that
> > "consist[s] of a single expression".. which I doubt is the reality
or
> > the intention.
> >
> > Regards,
> > Fuzzyman
> > http://www.voidspace.org.uk/python/index.shtml
> >
>
> [Sorry, I deleted the commented lines because they were completely
> unreadable anyway]
>

That's alright - I *have* to read via google, which hides quoted lines
anyway......

> It's exactly what eval is for : evaluate a single expression and
return
> its result ! Try with strings : you can't even evaluate a statement !

> You can only evaluate an expression !
>

Right.

> And what would be the return result of a sequence of statement ?
>

:-) I'm not interested in the return result. The code object is run in
the current namespace, so I use it to run scripts.

> If you want to execute a sequence, you want to use exec, not eval ...
>

Yup - I've swapped them over in my code.

Thanks
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> Pierre




More information about the Python-list mailing list