Kent Johnson schrieb: > Gregor Lingl wrote: > >>Thanks, Kent for the hint. It works (of course). >>Skimming through this part of the docs I discovered, that there is a >>special method __deepcopy__. So I also tried using this, adding >> >> def __deepcopy__(self,visit): >> return self >> >>to my Vec class, which also seems to work. (I think this not to >>be harmful as Vecs should be, like tuples, immutable). >>And, indeed, it also seems to work. > > > That is not a correct deep copy, it is a shallow copy. Although Vec > objects are immutable they may contain mutable objects. The point of > deep copy is to copy "all the way down" so the objects contained by a > Vec should also be copied. O.k. I understand. It's just that my Vec class invariably has two numbers as elements (otherwise the abs-method wouldn't make sense. That's what I meant with 'Vecs are immutable'). So in my case it works, but would have to be considered bad style? Thanks, again Gregor > Kent > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27 Website: python4kids.net _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor