[Python-Dev] Declaring setters with getters (original) (raw)
Guido van Rossum guido at python.org
Thu Nov 1 18:35:31 CET 2007
- Previous message: [Python-Dev] Declaring setters with getters
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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/)
- Previous message: [Python-Dev] Declaring setters with getters
- Next message: [Python-Dev] Declaring setters with getters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]