This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients gvanrossum
Date 2007-11-10.05:58:08
SpamBayes Score 0.18886484
Marked as misclassified No
Message-id <1194674290.8.0.853140061818.issue1416@psf.upfronthosting.co.za>
In-reply-to
Content
Here's an implementation of the idea I floated recently on python-dev
(Subject: Declaring setters with getters).  This implements the kind of
syntax that I believe won over most folks in the end:

  @property
  def foo(self): ...

  @foo.setter
  def foo(self, value=None): ...

There are also .getter and .deleter descriptors.  This includes the hack
that if you specify a setter but no deleter, the setter is called
without a value argument when attempting to delete something.  If the
setter isn't ready for this, a TypeError will be raised, pretty much
just as if no deleter was provided (just with a somewhat worse error
message :-).

I intend to check this into 2.6 and 3.0 unless there is a huge cry of
dismay.  Docs will be left to volunteers as always.
Files
File name Uploaded
propset.diff gvanrossum, 2007-11-10.05:58:08
History
Date User Action Args
2007-11-10 05:58:11gvanrossumsetspambayes_score: 0.188865 -> 0.18886484
recipients: + gvanrossum
2007-11-10 05:58:10gvanrossumsetspambayes_score: 0.188865 -> 0.188865
messageid: <1194674290.8.0.853140061818.issue1416@psf.upfronthosting.co.za>
2007-11-10 05:58:10gvanrossumlinkissue1416 messages
2007-11-10 05:58:08gvanrossumcreate