compile() question

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Dec 21 11:40:52 EST 2001


afabbro at indoctrination.com (afabbro) writes:

>   exec ( 'volume.' + field + ' = "' + value + '"' )
> 
> which means the exec'd python code is something like:
> 
>   volume.barcode = 'T00123'
> 
> So far, so good.

exec is not good. What's wrong with

setattr(volume, field, value)

HTH,
Martin



More information about the Python-list mailing list