[Python-Dev] defaultdict and on_missing() (original) (raw)

Walter Dörwald walter at livinglogic.de
Thu Feb 23 22:55:40 CET 2006


Guido van Rossum wrote:

On 2/22/06, Michael Chermside <mcherm at mcherm.com> wrote:

A minor related point about onmissing():

Haven't we learned from regrets over the .next() method of iterators that all "magically" invoked methods should be named using the xxx pattern? Shouldn't it be named onmissing() instead? Good point. I'll call it missing. I've uploaded a new patch to python.org/sf/1433928.

I always thought that magic method calls are done by Python on objects it doesn't know about. The special method name ensures that it is indeed the protocol Python is talking about, not some random method (with next() being the exception). In the defaultdict case this isn't a problem, because defaultdict is calling its own method.

Bye, Walter Dörwald



More information about the Python-Dev mailing list