Interesting thread on comp.lang.perl.misc

ze5yr ze5yr at
Fri Aug 13 19:07:04 EDT 1999

In article <Pine.GSO.4.10.9908131047510.3761-100000 at>,
  japhy at wrote:
> I wish I could change a string in-place with a function.*
> [bobbit]
> * meaning:
> def func(str):
>   # something modifying str
> str = "foo"
> func(str)
> print str # prints... "bar", for example

Enclose it in a list, which is mutable:

def func(l):

>>> l=["foo"]
>>> func(l)
>>> print l

A little clumsy, but it works!

Cliff Crawford                           -><-
                            empty-handed I go,
)O(       and behold the spade is in my hands

Sent via
Share what you know. Learn what you don't.

More information about the Python-list mailing list