Can Python do this?

brueckd at tbye.com brueckd at tbye.com
Tue Mar 5 10:51:33 EST 2002


On Tue, 5 Mar 2002, Gerhard Häring wrote:

> > Can you tell me little bit more why is this a bad idea to use exec/eval?
>
> Because they're
> - unnecessary
> - ugly
> - unsafe

And:
- slow

For example:

s = 'bar'
getattr(foo, s)

is way faster than

eval('foo.%s' % s)

-Dave





More information about the Python-list mailing list