is there a better way to walk a file system?

Peter Otten __peter__ at
Fri Jul 1 19:02:23 CEST 2005

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)
>>> sorted([A(42), A(2), A(4)], key=A.value.__get__)
[A(2), A(4), A(42)]


More information about the Python-list mailing list