[Python-3000] Special methods and interface-based type system
Bill Janssen
janssen at parc.com
Wed Nov 22 23:05:09 CET 2006
> Saying the same thing in another way, I see 'len' as a built-in
> *operation*. I'd hate to lose that. I can't say for sure whether you
> meant that or not, but 'def len(self): ...' certainly sounds like you
> want to demote it to an ordinary method. I'm strongly -1 on that.
OK, I can see that. So the built-in function len() and its cousins
should be thought of as special Python syntax. I see no real reason
to remove that; if "<" just invokes a standard method
"orderable.lessthan", the built-in len can just invoke
"container.len". But foo.len() would also be available for use.
> I didn't want these special operations to use ordinary
> method names, because then pre-existing classes, or classes written by
> users without an encyclopedic memory for all the special methods,
> would be liable to accidentally define operations they didn't mean to
> implement, with possibly disastrous consequences.
Hmmm. This seems kind of a weak rationale to me, but OK.
Bill
More information about the Python-3000
mailing list