Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
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): >> r

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Kent Johnson
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 clas

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
Kent Johnson schrieb: > Gregor Lingl wrote: > >>Hi all of you, ... >>> from copy import deepcopy >> >>> class Vec(tuple): >> def __new__(cls, x, y): >> return tuple.__new__(cls, (x,y)) >> def __abs__(self): >> return (self[0]**2+self[1]**2)**0.5 >> ##

Re: [Tutor] question concerning deepcopy

2006-04-28 Thread Kent Johnson
Gregor Lingl wrote: > Hi all of you, > > I've some Vector class, which is a subclass of tuple and which is > working satisfactorily since long in different contexts. Now I've > constructed objects with attributes of Vec-type, which I wanted to > deepcopy. But that doesn't work, because I can't

[Tutor] question concerning deepcopy

2006-04-28 Thread Gregor Lingl
Hi all of you, I've some Vector class, which is a subclass of tuple and which is working satisfactorily since long in different contexts. Now I've constructed objects with attributes of Vec-type, which I wanted to deepcopy. But that doesn't work, because I can't (deep)copy Vec-s: >>> from cop