Feb. 18, 2007
4:25 a.m.
"Jim Jewett" <jimjjewett@gmail.com> 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 - Josiah