indexed property? Can it be done?

Adam Tauno Williams awilliam at whitemice.org
Tue May 8 16:19:41 EDT 2012


On Mon, 2012-05-07 at 20:15 -0700, Charles Hixson wrote: 
> class Node:
>      def    __init__(self, nodeId, key, value, downRight, downLeft, parent):
>          dirty    =    True
>          dlu    =    utcnow()
>          self.node    =    [nodeId, downLeft, [key], [value], 
> [downRight], parent, dirty, dlu]
> Note that node[3] is a list of keys (initially 1) and node[3] is a list 
> of values, etc.
> What I'd like to do is to be able to address them thusly:
> k = node.key[2]
> v = node.value[2]
> but if there's a way to do this, I haven't been able to figure it out.  
> Any suggestions?

Do not do this;  this is bad code in any language.  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20120508/9b619d31/attachment-0001.sig>


More information about the Python-list mailing list