Method objects question

Tim Peters tim_one at email.msn.com
Sat Nov 27 04:48:40 CET 1999


[Ben Caradoc-Davies]
> ...
> But the point is, why should functions found in a class namespace be
> converted into methods, but functions found in an instance namespace
> not converted?

Both behaviors are useful, depending on the application.  Guido picked the
behaviors for each mechanism that he judged would be most useful most often.
An obvious way to give some particular set of objects different behavior in
response to a msg is via subclassing (i.e., the class mechanism need not be
"abused" to achieve that end).

> ...
> In a nutshell, I don't see any fundamental reason why the search-
> instance-namespace then search-class-namespace attribute resolution
> order couldn't be used to allow method overriding on an
> instance-by-instance basis.

There is no "fundamental" reason.  I like it the way it is, but it's too
late to change now regardless.

> With the current, function-to-method conversion rules, this is
> impossible.

As has been explained by others, it's not impossible, just clumsy.  If the
language had been defined your way, binding an instance attribute to a plain
function would have been (at best) clumsy instead, and we'd be reading msgs
now complaining about that instead <0.4 wink>.

"the-class-determines-the-meaning-of-a-msg"-is-conventional-ly y'rs  - tim






More information about the Python-list mailing list