On Fri, 30 Jan 2009 09:43:39 -0600 "Edward K. Ream" <[email protected]> wrote:
> On Fri, Jan 30, 2009 at 9:20 AM, Terry Brown > <[email protected]>wrote: > > > > > On Fri, 30 Jan 2009 06:40:09 -0800 (PST) > > "Edward K. Ream" <[email protected]> wrote: > > > > > p.v.u [key] = val > > > val = p.v.u [key] > > > > > > There seems to be no direct way to specify a key. Instead, p.v.u > > > will return an instance of uAaccessor class that provides get/set > > > methods: > > > > It doesn't work to just have p.v.u return the dict (having created > > it if required)? > > No. Setting that dict would have no effect on the actual uA. class MaybeAttr(object): @property def u(self): if not hasattr(self, 'unknownAttributes'): self.unknownAttributes = {} return self.unknownAttributes x = MaybeAttr() print 'X:',hasattr(x, 'unknownAttributes') if 'odd' in x.u: print "That's odd" print 'X:',hasattr(x, 'unknownAttributes') y = MaybeAttr() y.u['test'] = 42 print y.u['test'] print y.unknownAttributes['test'] output: X: False X: True 42 42 Am I missing something here? Cheers -Terry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en -~----------~----~----~----~------~----~------~--~---
