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
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]
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
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
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
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
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
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
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