Choosing a programming language as a competitive tool

Alex Martelli aleaxit at
Mon May 7 11:31:35 CEST 2001

"Konrad Hinsen" <hinsen at> wrote in message
news:m3r8y21ddd.fsf at
> "Alex Martelli" <aleaxit at> writes:
> > Python's so-called "lists" are really vectors, or arrays,
> > of references -- the references are stored in a contiguous slab of
> I suppose that for ordinary mortals who haven't studies computer
> science, Python lists correspond exactly to what they call lists in
> their daily life!

Maybe to some of them -- if order is "somewhat important", but
not TOO much.

> Konrad, who doesn't link items on his shopping lists.

Suppose for the sake of argument that you do not care at
all about the order of items on your shopping lists.  Then,
they're really sets.  When comparing two shopping lists to
see if you've bought the same things on successive weeks,
you would consider
as "equal" to

But lists in Python (and LISP) don't really work that way;
an == test between ['eggs','milk'] and ['milk','eggs'] will
not return a true value.  One can use lists (of any kind)
as one way to _represent_ sets, but this takes work and
often throws up side issues.

Support your shopping lists ARE order-significant.  For
example, you list items you desire in decreasing order
of importance, and buy each item if available in strictly
that order until you run out of money or have bought all
available items.

Then, it might make sense to keep your "shopping list"
as a set of separate little pieces of paper rather than
write it out each week.  That way, most of the time
"doing the list" will just mean ordering things in
the appropriate way, no writing necessary.  Of course,
this does make it harder, given a list, to find "the
7th item down that list" -- you need to count -- but
that's OK, as you do not particularly care for that
sort of access for shopping-list use.  And if you
change your mind at the last minute and decide you
need to add, say, 'spam', as the first or second item,
it's no biggie -- just insert the little piece of paper
at the right spot, which is very fast, and you're OK.

These would be LISP lists, or C++ lists, or close
to that.

If you choose to write down your list on lined paper:
    1. eggs
    2. milk
    3. cereals
    (& c)
then it's easier to see what item is (e.g.) in 7th
place (your eyes can pattern-match "7." faster than
counting) -- but who cares?  Rather, think of the
problems that come when you suddenly decide that
the number 2 spot needs to have 'spam' and all the
rest need to move down one slot.  Eeek!  If you're
a neat, orderly person you won't stand for a hastily
re-scribbled list with '2.' rubbed out and '3.' in
its place, etc, and '2. spam' written in small and
skewed hand to "fit" between eggs and milk.  Nope,
you'll have to copy the whole things out to a fresh
piece of paper to have your list be right again.

These would be Python lists, or close to that.

My shopping lists are closest to being representations
of sets, with order irrelevant (and, in theory, no
duplicates -- though I do slip up and end up writing
again an item that WAS already there higher up on the
list... and I think this issue is widespread:-).

For everyday use, I guess both Lisp/C++/Haskell/ML/...
lists, and Python lists, come just about equally close
to what somebody could be used to in terms of a
"shopping list".  Depending on your electoral system,
however, another common use, a "party list", might be
far closer to what Python, Haskell, ML &c call a
*tuple* (where write-in candidates are allowed, though,
the closeness to immutable tuples recedes:-).


More information about the Python-list mailing list