18 Feb
2007
18 Feb
'07
4:25 p.m.
Well, except that Raymond's is indeed better -- so consider this a
request for inclusion in 2.6
On 2/17/07, Josiah Carlson
"Jim Jewett"
wrote: class Vector3D(tuple): ... def __new__(self, x, y, z): ... return super(Vector3D, self).__new__(self, (x, y, z)) ... x=property(lambda self: self[0]) ... y=property(lambda self: self[1]) ... z=property(lambda self: self[2])
That looks very much like Raymond Hettinger's named tuple recipe, recently offered in python-dev:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/500261
-jJ