[Python-ideas] C# style properties

Josiah Carlson jcarlson at uci.edu
Fri Jul 13 09:16:25 CEST 2007

Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Josiah Carlson wrote:
> >     class foo:
> >         class a(Property):
> >             ''' documentation '''
> >             def get(self):
> >                 return self._a
> >             ...
> > 
> > I'm curious as to why this still gets
> > brought up when the obvious syntax is more or less identical to
> > basically all reasonable alternate syntaxes.
> I would dispute that anything involving a class statement
> that creates something other than a class is "obvious".

The "Property" statement that is longer, the existance of get/set/de1
methods, those didn't catch your eye?  What if the user plopped in a
nice big "__metaclass__ = Property" line?  Ugly or not, I find that it
has helped me organize (with indentation), not repeat myself, and not
have to clean up spare get/set/del methods.  I personally prefer it to
x = property(...), a property decorator, and a bazillion times more than
any property-specific syntax.

 - Josiah

More information about the Python-ideas mailing list