Fabiano Sidler wrote: > Have a look to the following lines of code: > --- snip --- > class Foo: pass > def bar(): pass > Foo.bar = bar > --- snap --- > > Why does 'bar.__get__(Foo) is Foo.bar' evaluate to False here? Did I > misunderstand the descriptor protocol?
bar.__get__(None, Bar) is what you meant (the first argument is the object, not the type), but even then the result will be False, because the __get__ method on functions returns a different object each time it's called: >>> class Foo(object): ... def bar(self): ... pass ... >>> Foo.bar is Foo.bar False -- http://mail.python.org/mailman/listinfo/python-list