How to replace a method in an instance.

Alex Martelli aleax at mac.com
Mon Aug 27 17:07:50 CEST 2007


Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com>
wrote:

> >>> Of course, a function in a
> >>> class is also know as a method.
> >> Less obvious but still wrong !-)
> > 
> > I wish the authors of the Python books would get a clue then.
> 
> I'd think that at least some authors of some Python books would explain
> all this much better than I did. But FWIW, all these rules are clearly
> documented in the Fine Manual.

Speaking as one such author, I think I do a reasonable job of this in
"Python in a Nutshell" (2nd ed): on p. 82 and 85 I have brief mentions
that "class attributes bound to functions are also known as methods of
the class" (p.82) and again that "functions (called methods in this
context) are important attributes for most class objects" (p.85); on
p.91-94, after explaining descriptors, instances, and the basics of
attribute reference, I can finally cover the subject thoroughly in
"Bound and Unbound Methods".  I realize that a beginner might be
confused into believing that "class attributes bound to functions" means
"function in a class", if they stop reading before p.91;-), but I don't
literally make that wrong assertion...;-)


Alex



More information about the Python-list mailing list