calling a function indirectly
jeff at ccvcorp.com
Mon Feb 25 21:57:08 CET 2002
Jim Dennis wrote:
> >> Why is eval dangerous?
> Regulars on this newsgroup display a knee jerk reaction to eval().
> This could be construed as a healthy wariness in some cases.
Another reason for the 'knee jerk reaction' is that eval() tends to lead to
unclear code. There's almost always some other way to do what you want, that is
much more explicit, and therefore easier to read and understand. In particular,
other ways are less likely to have hard-to-trace side effects. To my mind,
eval() is magic -- sometimes it's good to have, but you should always be wary
about using it. Less magic is better. (I won't go quite so far as to call
eval() black magic, but in some contexts it's definately pretty gray... ;) )
More information about the Python-list