Kris Schnee wrote:
When all else fails, copy.deepcopy() seems to make Python understand, "I want this to have _the same value_ as X now has, not to be a _reference_ to X."
I'd advise against using deepcopy() in a desperate attempt to make Python "seem to understand" something. That wording suggests more that there's something *you* don't understand about how your program works or is supposed to work. Personally I don't find deepcopy() much use at all, because usually when you want more than a shallow copy you want something less than a fully deep copy. For instance, if you have a 2d list of tiles, you want to copy 2 levels deep, but not copy the tiles themselves. And I'd be somewhat uncertain what deepcopy() would do if I let it loose on my tile objects. So I tend to be more comfortable writing my own copying functions tailored to specific circumstances. I don't think I've ever used deepcopy() or felt any need to use it. -- Greg