Hard to understand 'eval'

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Sat Jun 14 22:08:23 CEST 2008


On 14 juin, 10:31, TheSaint <fc14301... at icqmail.com> wrote:
> Hi,
>
> It seems to be strange that give me syntax error inside an eval statement.
> I'm looking at it carefully but I can't see any flaw.
>
> Here it's part of the code:
>
>         for nn in stn_items:
>         value= eval('cp.%s' %nn)

Hem... Not obvious from this snippet, but what's wrong with
getattr(cp, nn) ?




More information about the Python-list mailing list