Re: Update an object with a dictionary

2009-06-10 Thread Alex Gaynor
On Wed, Jun 10, 2009 at 4:56 PM, Kevin Teague wrote: > > __dict__ is an attribute of every Python object. It's typically only > an internal detail, and generally not accessed directly. One area > where __dict__ modification would differ from attribute access is with > an attribute that's a proper

Re: Update an object with a dictionary

2009-06-10 Thread Kevin Teague
__dict__ is an attribute of every Python object. It's typically only an internal detail, and generally not accessed directly. One area where __dict__ modification would differ from attribute access is with an attribute that's a property. Modifying the __dict__ would ignore the property getter/sett

Re: Update an object with a dictionary

2009-06-10 Thread Paolo Corti
> > .save() is only for persisting the object to disk, not for modifying > objects. To update any Python object from a dictionary is as easy as: > > for k,v in d.items(): setattr(myobject, k, v) this is also what i came to. But curious to try the Daniel's approach, will let you know best regards

Re: Update an object with a dictionary

2009-06-10 Thread Kevin Teague
On Jun 10, 9:27 am, Paolo Corti wrote: > Hi > is it possible to update an object with a dictionary? > > I tried something like this: > myobject.save(force_update=True, **my_dict) > > getting an error, though: > TypeError at ... > save() got an unexpected keyword a

Re: Update an object with a dictionary

2009-06-10 Thread Daniel Roseman
On Jun 10, 5:27 pm, Paolo Corti wrote: > Hi > is it possible to update an object with a dictionary? > > I tried something like this: > myobject.save(force_update=True, **my_dict) > > getting an error, though: > TypeError at ... > save() got an unexpected keyword a

Update an object with a dictionary

2009-06-10 Thread Paolo Corti
Hi is it possible to update an object with a dictionary? I tried something like this: myobject.save(force_update=True, **my_dict) getting an error, though: TypeError at ... save() got an unexpected keyword argument 'myfieldname' I wouldn't like to iterate the dictionary, neithe