Shed my a light :)

TheSaint fc14301589 at
Mon Jun 2 15:16:47 CEST 2008

On 19:06, lunedì 02 giugno 2008 Chris wrote:

>> actions= ('print', 'sum', 'divide', 'myfunction')
>> parameters=(5, 'nothing',5.63, object)

8< 8<
> getattr(...)
>     getattr(object, name[, default]) -> value
8< 8<
> for nn in actions:
>     func = getattr(cp, nn)
>     if callable(func):
>         func(parameters)
I got the point of Duncan and I should remain on evail() because the
evaluation is made on a construct of string expression, which give me the
final name of the function I want to call.
I've tried on Pyshell and clearly said the object str is not callable.

Some of those string are functions inside the module, so I was expecting a
sequence of calls according the passed in functions names, but they *must*
be processed as a python statements ;(

Mailsweeper Home :

More information about the Python-list mailing list