Hard to understand 'eval'
ironfroggy at socialserve.com
Sun Jun 15 19:15:25 CEST 2008
The point here is that eval() use is general frowned upon. If you
don't understand it or the alternatives, then you probably don't
understand it well enough to make the call on using it or not.
If you need just look up an attribute where the name of the attribute
is in a variable, use getattr(obj, attribute_name). If you need to
call a method somewhere, you should have both the name of the method
and the list of arguments to call it with, such as getattr(obj,
methname)(a, b, c). Does this make sense?
On Jun 15, 2008, at 5:16 AM, TheSaint wrote:
> On 04:08, domenica 15 giugno 2008 bruno.desthuilliers at gmail.com wrote:
>> what's wrong with getattr(cp, nn) ?
> The learning curve to get into these programming ways.
> Does gettattr run the snippet passed in?
> Considering that nn is a name of function, which will be called and
> value) are the parameters to passed to that function.
> I'll spend some bit on getattr use.
> Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
More information about the Python-list