Implicit lists

Erik Max Francis max at alcyone.com
Sat Feb 1 17:40:29 EST 2003


Christian Tismer wrote:

> You are right, in general. The problem is simply that
> strings can be treated as objects or sequences all
> the time, and that a common error is to pass a string
> in a sequence context, and your function iterates over
> the single chars. This especially hurts when your
> function expects a list of filenames, and suddenly it
> creates a bunch of single char named files :-)

I don't see how you can eliminate strings' sequence interface without
either 1. breaking a huge amount of code, or 2. ending up with a string
presenting a very mixed and fragmented interface.  Individual characters
are routinely indexed from strings, the lengths of strings (via len) are
routinely retrieved, and slicing (really a special case of the sequence
protocol) is exceptionally common.

So how do you make the string type support all these behaviors but _not_
act as a standard sequence?  Why would you really want to?

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Then you give me that Judas Kiss / Could you hurt me more than this
\__/ Lamya
    Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
 A personal guide to Aliens vs. Predator 2.




More information about the Python-list mailing list