[Python-Dev] PEP 318: Properties

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Apr 5 01:44:34 EDT 2004

Skip Montanaro <skip at pobox.com>:

>     Jim> I would expect 42 to be the initial value of the property x.
> Then it makes sense to put "x = 42" after the three property definitions
> (before the end of the class definition).  Would that work?

No, it would wipe out the property descriptor that you'd just
carefully set up.

I don't think this makes sense, anyway. Being a property implies that
its value is computed somehow, so how to establish an initial value,
if that concept even applies, will depend entirely on the details of
how it's being computed.  Sounds like a job for a piece of code in an
__init__ method to me.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list