list operation '+= ' or assignment problem
Aahz Maruch
aahz at panix.com
Thu Jan 4 10:57:29 EST 2001
In article <xX_46.2919$AH6.516601 at newsc.telia.net>,
Fredrik Lundh <fredrik at effbot.org> wrote:
>Joe Smith wrote:
>>
>> I guess that list assignment is an assignment of the reference
>> to the object and it does not copy the object. Where as a
>> string object gets copied.
>
>Alex: No.
>Erno: No.
>Greg: Yes, in a way.
>Steve: Yes.
>Tim: No.
>
>time for a poll? ;-)
No, but I'll explain why some people are saying "yes":
foo = "abc"
bar = foo
bar += "d"
bar now contains a reference to "abcd", which is a copy of the original
string "abc" plus the additional letter "d". Joe's usage of "copy" is
misleading and somewhat incorrect in a Python context, but it's not
completely out of the blue, either.
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"This is Usenet. We're all masturbating in public places." -DH
More information about the Python-list
mailing list