A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-November/075090.html below:

[Python-Dev] Declaring setters with getters

[Python-Dev] Declaring setters with getters [Python-Dev] Declaring setters with gettersGuido van Rossum guido at python.org
Thu Nov 1 18:35:31 CET 2007
On 11/1/07, glyph at divmod.com <glyph at divmod.com> wrote:
> This is a minor nit, as with all decorators that take an argument, it
> seems like it sets up a hard-to-debug error condition if you were to
> accidentally forget it:
>
>     @property
>     def foo(): ...
>     @property.set
>     def foo(): ...
>
> would leave you with 'foo' pointing at something that wasn't a
> descriptor at all.  Is there a way to make that more debuggable?

Yes, if you remember my initial post, it contained this line:

   assert isinstance(prop, property)

And even without that, accessing prop.fget would fail immediately; so
instead of a non-functioning property, you get an exception at class
definition time.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4