[google-appengine] A safer way to do dynamic property assignment?

2010-04-07 Thread J
I need to assign a value to a Model property but its name is not known until runtime. For illustrative purposes, say class Story(db.Model): title = db.StringProperty() body = db.TextProperty() s = Story(title=The Three Little Pigs) Since I wanted to decide on the property name at

Re: [google-appengine] A safer way to do dynamic property assignment?

2010-04-07 Thread Nick Johnson (Google)
Hi J, You can use getattr and setattr for dynamic property access: s = Story() setattr(s, 'title', 'The three little pigs') getattr(s, 'title') # Returns 'The three little pigs' On Wed, Apr 7, 2010 at 3:31 PM, J j.si...@earlystageit.com wrote: I need to assign a value to a Model property but