Python's "only one way to do it" philosophy isn't good?

Alexander Schmolck a.schmolck at
Mon Jun 25 17:37:53 CEST 2007

Douglas Alan <doug at> writes:

>> Python has built-in abstractions for a few container types like
>> lists and dicts, and now a new and more general one (iterators), so
>> it's the next level up.
> Common Lisp has had all these things for ages.

Rubbish. Do you actually know any common lisp?

There is precisely no way to express

    for x in xs:

    x = xs[key]

in either scheme or CL, which is a major defect of both language (although
there has been a recent and limited proposal for sequence iteration by c.
rhodes which is implemented as an experimental extension in sbcl). This is
stuff even C++, which is about the lowest-level language anyone uses for
general purpose programming these days has been able to express for decades
(modulo foreach syntax).

In a decent scheme it's easy enough to define your own collection
class/iteration protocol, which does allow you to do something like the above,
but of course only for container abstractions that you have some control over
yourself. Even in this limited sense you can forget about doing this in CL in
a way that meshes nicely with the existing primitives (inter alia because of
spurious inconsistencies between e.g. sequence and hash-access and
under-specification of the exception hierachy) and anything as expressive as
generators/coroutines in CL with reasonable effort and performance which won't
even allow you to write LOOPs over custom container types (the nonstandard
ITERATE package has limited support for this).


More information about the Python-list mailing list