Newbi Q: What is a rational for strings not being lists in Python?

Simon Brunning simon at brunningonline.net
Mon Oct 15 11:12:22 EDT 2007


On 10/15/07, Dmitri O.Kondratiev <dokondr at gmail.com> wrote:
> To clarify my point:
> reverse()  is  a lucky one  - Python has variants of *this particular*
> function both for lists and strings. Yet what about other list functions?
> How in general, can I write a function that works  both on list and string
> types? Both are sequences, right? Why string is not a subtype of a list
> then?

Lists are mutable, strings are not, so so strings can't support all a
list's methods.

-- 
Cheers,
Simon B.
simon at brunningonline.net
http://www.brunningonline.net/simon/blog/
GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues



More information about the Python-list mailing list