compile() question
Jason Orendorff
jason at jorendorff.com
Wed Dec 19 18:31:34 EST 2001
More information about the Python-list mailing list
Wed Dec 19 18:31:34 EST 2001
- Previous message (by thread): compile() question
- Next message (by thread): index()-like behavior that returns all occurences...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> I am parsing a stream of colon-delimited fields (field:value) where > the field is an attribute for an object. Since there are a few dozen > fields and I don't want to handle each field separately, I used exec > to make it easy (after splitting): > > exec ( 'volume.' + field + ' = "' + value + '"' ) This is a slow approach (plus it fails if there are " characters in the value). Try this instead: setattr(volume, field, value) ## Jason Orendorff http://www.jorendorff.com/
- Previous message (by thread): compile() question
- Next message (by thread): index()-like behavior that returns all occurences...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list