On Feb 21, 2005, at 10:29 PM, Charles Hartman wrote:

On Feb 21, 2005, at 9:15 PM, Bob Ippolito wrote:

Note that strings are immutable in Python, and if "Dict" has strings for values then the copy-by-slice is extraneous. There's no reason to make a copy of an object that can't possibly be changed. I'm pretty sure that slicing a string like that is going to return the same object anyway.

The value (not the key) is a list of strings. The strings are immutable, but (if I understand rightly) the list is not. Without the slice-copy, when I later replace one of the strings *in* the list, the dictionary's own list gets changed.

Yeah, that's correct. I had misread the part of your post that said the values were lists.


-bob

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to