Why is Python popular, while Lisp and Scheme aren't?

Alexander Schmolck a.schmolck at gmx.net
Sun Nov 24 13:46:36 EST 2002


"Delaney, Timothy" <tdelaney at avaya.com> writes:


> I OTOH fall firmly in the category of people who prefer 'for x in dict' to
> iterate over the keys. In my own code I rarely use 'dict.values()', but very
> often use 'dict.keys()'. I am more likely to use 'dict.items()' than
> 'dict.values()' and think this would have been the other logical choice for
> iteration over a dict (i.e. returning key, value).
> 
> The most common case should be used for the shortest form.

All other things being equal, yes of course. But I think they aren't equal
because you loose an useful abstraction for the dubious gain of having 7
characters less to type.

Both sequences and dicts map keys to values and so do many other container
types and thus their interfaces should reflect that underlying similarity. For
one that allows you to replace dicts and lists in places in your code where
you only need a mapping between numbers and values and either a list or a dict
might in the end turn out to be the best way to achieve that goal.

Similarly also can't see a good conceptual or pragmatic reason why all lists
shouldn't have .get, .items. etc. indeed a .get method for sequence types
would be often quite useful and being able to write

  for i, elt in seq.items():...

Also, you might want to have a container class that has attributes of both a
list and a dict, say an ordered dict and the current semantics make this
awkward.


alex



More information about the Python-list mailing list