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

Neil Cerutti horpner at yahoo.com
Mon Oct 15 13:06:20 EDT 2007


On 2007-10-15, Simon Brunning <simon at brunningonline.net> wrote:
> 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.
>



More information about the Python-list mailing list