Implicit lists

Erik Max Francis max at alcyone.com
Thu Jan 30 23:19:49 EST 2003


Dale Strickland-Clark wrote:

> Except it doesn't work :-)

For "doesn't work," you mean "didn't do what I expected it to do for my
own purposes but never indicated to the audience I'm posing the question
to, so they couldn't possibly know."  Python emphasizes interfaces more
than types; a string _is_ a sequence (in that it presents a sequence
interface to its users), so if you pass it to a function that expects a
sequence, it should treat it as a sequence.

As I mentioned in an earlier post, I think the problem here is that
you're trying too hard to implement type-based dispatched in a dynamic
language.  That generally isn't a good idea (though there's some cases
where it's appropriate), because of the very nature of dynamic languages
-- you should be concentrating not on the _types_ of the objects, but
their behavior.

Wouldn't it be more appropriate to have _two_ functions, one which takes
a sequence, and one which takes a single object (and possibly simply
wraps it in a one-element list and passes it to the sequence-taking
function)?

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ The great artist is the simplifier.
\__/ Henri Amiel
    Sade Deluxe / http://www.sadedeluxe.com/
 The ultimate Sade encyclopedia.




More information about the Python-list mailing list