George Sakkis wrote:

> By the way, from this example I discovered that properties cannot be
> unbound, i.e. using path.ext instead of getExtension raises TypeError.
> Couldn't/shouldn't Class.prop(instance) be allowed as equivalent of
> instance.prop, just as methods ?
 
Use the property's __get__() method instead:

>>> class A(object):
...     def __init__(self, value):
...             self._value = value
...     value = property(lambda self: self._value)
...     def __repr__(self): return "A(%r)" % self._value
...
>>> a = A(42)
>>> A.value.__get__(a)
42
>>> sorted([A(42), A(2), A(4)], key=A.value.__get__)
[A(2), A(4), A(42)]

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to