[Edu-sig] Design patterns

Arthur ajsiegel at optonline.net
Sun Aug 21 14:49:09 CEST 2005

> -----Original Message-----
> From: edu-sig-bounces at python.org [mailto:edu-sig-bounces at python.org] On
> Behalf Of Scott David Daniels
> Here's how to do the angles in 2.4 w/ properties:


>      @property
>      def A(self):
>     	return math.acos((-self.a**2 + self.b**2 + self.c**2)
> 			 / (2.0 * self.b * self.c))


We seem to be saying that @property works out-of-the box as a decorator in
2.4 - at least where we want read only properties. 

I can only assume that this is more of a side-effect of the introduction of
decorators, than a feature fully designed into the language. Which is not to
say that it is not a fortunate side effect.

But it is unfortunate combo for me - since I never fully understood the
purpose of properties, and don't fully get the mechanics of decorators.  

My most important points of confusion:

What beyond sugar for leaving off a "()" when trying to retrieve a value
from a method are we accomplishing by using properties? I have tended to
look at properties mostly  an accommodation to those coming from other
languages which have something similar, but never as something that was core
to Python or a Pythonic approach to things.  Am I missing something


Am I correct that the use of property as a "built-in" decorator is not
designed into the language  - at least in the same way that @classmethod has
been? What would it take to create a @property decorator that allows one to
set as well as get? Would we want to?


More information about the Edu-sig mailing list