Hard to understand 'eval'
fc14301589 at icqmail.com
Sat Jun 14 10:31:35 CEST 2008
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)
if value and (nn in 'log, trash, multithread, verbose, download'):
cnfg= 'cfl[wchkey][nn]= _%s(value)' %nn
And the output on pdb:
(Pdb) p cnfg
(Pdb) p cfl[wchkey][nn]
(Pdb) eval('cfl[wchkey][nn]= _append(value)')
*** SyntaxError: invalid syntax (<string>, line 1)
(Pdb) p value
(Pdb) p nn
Obviously I've an _append() function to convert into decimal the given value.
Other "eval" before this not issuing problems and also rather complicated,
but I'm not seeing the error here.
I'd like to study a class that might get a string and convert it into
function, once it's found inside the program.
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
More information about the Python-list