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

2007-10-16 Thread Dmitri O.Kondratiev
On 10/16/07, Matt McCredie [EMAIL PROTECTED] wrote: [quote] The example you posted won't work with tuples either because they, like strings, are also immutable. So, the best way to get the posted code to work (which is a bad way to go about reversing a string, but I digress) [end-quote] I

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

2007-10-16 Thread Simon Brunning
On 10/16/07, Benjamin [EMAIL PROTECTED] wrote: Good explanation, but basically strings are immutable so they can be used in dicts. Nope. Value types should always be immutable. http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable -- Cheers, Simon B. [EMAIL PROTECTED]

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

2007-10-16 Thread Neil Cerutti
On 2007-10-16, Simon Brunning [EMAIL PROTECTED] wrote: On 10/16/07, Benjamin [EMAIL PROTECTED] wrote: Good explanation, but basically strings are immutable so they can be used in dicts. Nope. Value types should always be immutable. http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable And

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

2007-10-16 Thread Paul McGuire
On Oct 15, 3:03 pm, Matt McCredie [EMAIL PROTECTED] wrote: So, the best way to get the posted code to work [...] is to cast the input parameter to a list first. snip s = I am a string x = list(s) x ['I', ' ', 'a', 'm', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g'] .join(x) 'I am a

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

2007-10-15 Thread Dmitri O.Kondratiev
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

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

2007-10-15 Thread Simon Brunning
On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] 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

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

2007-10-15 Thread Neil Cerutti
On 2007-10-15, Simon Brunning [EMAIL PROTECTED] wrote: On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] 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

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

2007-10-15 Thread Matt McCredie
On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] 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

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

2007-10-15 Thread Benjamin
On Oct 15, 3:03 pm, Matt McCredie [EMAIL PROTECTED] wrote: On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] 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