str is very much immutable. So you can't even set some custom attribute. For that you have to sublass. Look what happens, when you subclass str and get some mutable class this way:
In [10]: class A(str): ....: pass In [11]: a=A() In [13]: copy(a) is a Out[13]: False while copy is the identity on str. Cheers, Michael Am 02.08.2010 um 11:08 schrieb Sebastian Pancratz: > On 2 Aug, 09:57, Michael Brickenstein <brickenst...@mfo.de> wrote: >> I just tried it and the standard library functions also use that >> "optimization". >> >> In [1]: from copy import copy >> >> In [2]: l="slkl" >> >> In [3]: copy(l) is l >> Out[3]: True >> >> Cheers, >> Michael > > Perhaps my knowledge of Python isn't strong enough, but I guess > strings actually *are* immutable, as opposed to the way that > polynomials in Sage are only kind of immutable. This makes it > perfectly alright to have "copy" return the object itself. However, > if you are a user of Sage wanting to use the "_unsafe_mutate" option, > I think you really want copy to give you an independent "copy", don't > you? > > Kind regards, > Sebastian > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org ------------------------------------------- Michael Brickenstein Mathematisches Forschungsinstitut Oberwolfach gGmbH Schwarzwaldstr. 9 - 11 77709 Oberwolfach Tel.: 07834/979-31 Fax: 07834/979-38 -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org