Hard to understand 'eval'

TheSaint fc14301589 at icqmail.com
Sun Jun 15 21:12:39 EDT 2008


On 01:15, lunedì 16 giugno 2008 Calvin Spealman wrote:

> such as getattr(obj,
> methname)(a, b, c). Does this make sense?

This is big enlightenment :) Thank you! :)

I found problem with eval() when it comes to pass quoted strings.
I circumvent that by encapsulating the strings in variable or tuple.
The principle is to have a name which will refers a function somewhere in the
program and to call that function, plus additional data passed in.

In other word I'd expect something:

function_list= ['add' ,'paint', 'read']
for func in function_list:
      func(*data)
I tried getattr, and I saw that result. I only investigate a little, so I
still have a small perplexity.

-- 
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html



More information about the Python-list mailing list