[Python-ideas] Callable properties
fuzzyman at voidspace.org.uk
Mon Jun 7 15:40:36 CEST 2010
On 7 June 2010 12:34, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> I think you misunderstood, he was suggesting making the property descriptor
> instances callable.
> Not a bad idea, but as a change to a builtin it would be covered by the
> language moratorium. Easy to do in a subclass of property though.
> At the moment you do the following, which is a bit ugly:
> >>> class Foo(object):
> ... @property
> ... def foo(self):
> ... return 'foo'
> >>> f = Foo()
> >>> Foo.foo.__get__(f)
> The reason for wanting to do this are the same reasons as you would call an
> unbound method.
Or this which is still slightly ugly but at least gets rid of the magic
>>> class Foo(object):
... def foo(self):
... return 'foo'
>>> f = Foo()
>> Python-ideas mailing list
>> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas