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

Terry Reedy tjreedy at udel.edu
Wed Mar 1 08:29:44 CET 2006


"Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote in message news:44052636.9090709 at canterbury.ac.nz...

And you don't think there are many different types of iterables? You might as well argue that we don't need len() because it "only applies to sequences".

Since you mention it..., many people have asked on c.l.p why len() is a builtin function rather than a method of sequences (and other collections) (as .len, not .len). Some have suggested that it should be the latter. The answers justifying the status quo have been twofold.

  1. Before 2.2, not all builtin sequence types had methods (str and tuple), so they could not have a .len method. (This begs the question of why not, but that is moot now.)
  1. Before the addition of list comprehensions, a function could be mapped much more easily than a method

Terry Jan Reedy



More information about the Python-Dev mailing list