[New-bugs-announce] [issue1416] @prop.setter decorators

Guido van Rossum report at bugs.python.org
Sat Nov 10 06:58:10 CET 2007

New submission from Guido van Rossum:

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:

  def foo(self): ...

  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.

assignee: gvanrossum
files: propset.diff
keywords: patch
messages: 57345
nosy: gvanrossum
priority: normal
severity: normal
status: open
title: @prop.setter decorators
versions: Python 2.6, Python 3.0
Added file: http://bugs.python.org/file8724/propset.diff

Tracker <report at bugs.python.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: propset.diff
Type: text/x-patch
Size: 3094 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071110/39147308/attachment.bin 

More information about the New-bugs-announce mailing list