[Python-ideas] immutable classes [was: pre-PEP: Default Argument Expressions]
Jim Jewett
jimjjewett at gmail.com
Sun Feb 18 17:25:55 CET 2007
Well, except that Raymond's is indeed better -- so consider this a
request for inclusion in 2.6
On 2/17/07, Josiah Carlson <jcarlson at uci.edu> wrote:
>
> "Jim Jewett" <jimjjewett at 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
-jJ
More information about the Python-ideas
mailing list