On Jan 28, 2:13 pm, "Edward K. Ream" <[email protected]> wrote:
> How about p.u for 'unknown attributes'?
I don't know how to do the following:
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:
print p.v.u.get('key')
p.v.u.set('key','abc')
print p.v.u.get('key')
yields:
None
abc
I think this will be good enough. Can anyone think of a more clever
way? Here is the present code.
class uAaccessor (object):
'''A class providing get/set access to uA's'''
def __init__ (self,v):
self.v = v
def get (self,key):
v = self.v
if hasattr(v,'unknownAttributes'):
return v.unknownAttributes.get(key)
else: return None
def set (self,key,val):
v = self.v
if not hasattr(v,'unknownAttributes'):
v.unknownAttributes = {}
v.unknownAttributes[key] = val
def __get_u(self):
v = self
return self.uAaccessor(v)
u = property(
__get_u, __get_u, # getters and setters are the same.
doc = "vnode unknownAttribute property")
Edward
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---