On Mar 2, 8:19 pm, Paul <webjog...@gmail.com> wrote: > class User(object): > def __init__(self, uid): > self.uid = uid > self.__dict__.update(yaml.load(str('uid')+'.yaml')) > > def save(self): > f=open(str(self.uid)+'.yaml') > yaml.dump(self.__dict__, f) > > is there a better way to persist using Yaml > > Paulhttp://bidegg.com
Just a design consideration: Perhaps you want a separate dictionary to contain the YAML attributes. You can delegate extra objects to it with getattr and setattr. Or get extra objects with getitem and setitem. Otherwise, you might want 'save' and 'uid' to have a leading underscore. By better, do you mean more concise, easier to access, more robust, or etc.? -- http://mail.python.org/mailman/listinfo/python-list