[Python-Dev] Extended Function syntax (original) (raw)
"Martin v. L�wis" martin@v.loewis.de
Fri, 24 Jan 2003 12:52:32 +0100
- Previous message: [Python-Dev] Extended Function syntax
- Next message: [Python-Dev] Extended Function syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Duncan Booth wrote:
How about this:
class A(object): def foo(self, foo) [property.set]: "Setter for property 'foo'." _self.foo = foo def foo(self) [property.get]: "Getter for property 'foo'." _return self.foo
This is beautiful, but it does not work: when defining the getter, you need both the old property, and the new function object. Looking at your code
def set(fn):
if isinstance(fn, property):
return property(fn.fget, fn, fn.fdel, fn.__doc__)
you first assume fn is the property object, and then assume it is the setter function.
Of course, there is no reason why the namespace-under-construction couldn't be passed to the annotation, but that would be an extension to the protocol.
Martin
- Previous message: [Python-Dev] Extended Function syntax
- Next message: [Python-Dev] Extended Function syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]