On Fri, 3 Feb 2006 15:27:51 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
>"Magnus Lycka" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> [EMAIL PROTECTED] wrote:
>> Today, Python has a syntactic shortcut. If 'a' is an
>> instance of class 'A', a.f(x,y,z) is a shortcut for
>> A.f(a,x,y,z). If you don't use the shortcut, there is
>> no magic at all, just the unusual occurence of a type
>> check in Python!
>
>As was once pointed out to me some years ago, when I wrote something
>similar, a.f() is not just a shortcut for A.f(a) [a.__class__.f(a)]. The
>latter only looks for f in the class A namespace while the former also
>looks in superclass namespaces. The 'magical' part of accessing functions
>via instances is the implementation of dynamic inheritance.
I'm not sure I follow. Surely you're not suggesting that this doesn't work:
>>> class X:
... def foo(self):
... print 'X.foo', self
...
>>> class A(X):
... pass
...
>>> o = A()
>>> A.foo(o)
X.foo <__main__.A instance at 0xb7cab64c>
>>>
But I can't think what else you might mean.
>
>Terry Jan Reedy
>
>
>
>--
>http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list