On Jul 15, 11:55 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > I just came across this unusual situation where I'd like to modify a
> > string passed to a function
>
> Again: Why? The normal way to do this is to create a new string and
> return that.
>
Yes, usually, bu
[EMAIL PROTECTED] writes:
> I just came across this unusual situation where I'd like to modify a
> string passed to a function
Again: Why? The normal way to do this is to create a new string and
return that.
> which seems impossible since Python passes arguments by value.
No, Python passes argu
On Jul 15, 6:46 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi everyone,
>
> > I've heard that a 'str' object is immutable. But is there *any* way to
> > modify a string's internal value?
>
> > Thanks,
> > Sebastian
>
> Why would you care? Just create a new string (wi
[EMAIL PROTECTED] wrote:
Hi everyone,
I've heard that a 'str' object is immutable. But is there *any* way to
modify a string's internal value?
Thanks,
Sebastian
Why would you care? Just create a new string (with the changed contents) and
let garbage collection take care of the old one when
On Jul 15, 3:06 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > I've heard that a 'str' object is immutable. But is there *any* way to
> > modify a string's internal value?
>
> If there were, it would not be immutable. The 'str' type has only
> immutable values.
>
> You co
[EMAIL PROTECTED] wrote:
Hi everyone,
I've heard that a 'str' object is immutable. But is there *any* way to
modify a string's internal value?
In 3.0, ascii chars and encoded unicode chars in general can be stored
in a mutable bytearray.
--
http://mail.python.org/mailman/listinfo/python-l
Sebastian:
> I've heard that a 'str' object is immutable. But is there *any* way to
> modify a string's internal value?
No, but you can use other kind of things:
>>> s = "hello"
>>> sl = list(s)
>>> sl[1] = "a"
>>> sl
['h', 'a', 'l', 'l', 'o']
>>> "".join(sl)
'hallo'
>>> from array import array
>
[EMAIL PROTECTED] writes:
> I've heard that a 'str' object is immutable. But is there *any* way to
> modify a string's internal value?
If there were, it would not be immutable. The 'str' type has only
immutable values.
You could implement your own string type, and have it allow mutable
values. Y
Hi everyone,
I've heard that a 'str' object is immutable. But is there *any* way to
modify a string's internal value?
Thanks,
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list