On Sep 17, 11:14 pm, alex23 <wuwe...@gmail.com> wrote: > On Sep 18, 1:27 pm, rantingrick <rantingr...@gmail.com> wrote: > > > ok i have a class and in it's constructor i want to create a copy of > > it as an attribute, i have tried super, __new__, and noting seems to > > work, please help! > > > class A(base): > > def __init__(self): > > super(A, self).__init__() > > self.nested = ? > > > think of a nested list [ [] ] but with object "A" as the toplevel list > > and having an instance of A in the attribute "nested" > > Sorry, do you want an a copy of the instance or of the class? > > If you mean the class, self.nested = self.__class__ > If you mean the instance, self.nested = self
No i want an *actual* separate instance inside the current instance bound to an attribute "nested". But the problem is how to do this in the constructor without causing infinite recursion. I thought about creating an object copy function which would initialize the object and *then* return it to the constructor but that seemed kind of kludgy. There must be some syntax for doing this? -- http://mail.python.org/mailman/listinfo/python-list