Python and generic programming

Oliver Fromme olli at haluter.fromme.com
Wed Oct 27 14:19:30 CEST 2004


Christophe Cavalaria <chris.cavalaria at free.fr> wrote:
 > Oliver Fromme wrote:
 > > The appropriate type checking is done at compile time.  That
 > > is, if your program calls sort with two lists of different
 > > type (e.g. a list of strings and a list of ints), then the
 > > compiler will detect that and report an error.
 > 
 > This must be a bad example because I expect to be able to sort a list of
 > integers and a list of strings with the same sort function.

Uhm, I'm sorry, please forget the second sentence in my
above paragraph.  I had my mind somewhere else.  :-)

You _can_ use the function to sort a list of strings as
well as a list of ints.  But you can't mix it in a way
that, at some point, a string is compared with an int.

Best regards
   Oliver

-- 
Oliver Fromme, Konrad-Celtis-Str. 72, 81369 Munich, Germany

``All that we see or seem is just a dream within a dream.''
(E. A. Poe)



More information about the Python-list mailing list