Re: [Tutor] Instantiate a subClass using an instance of its baseClass

2006-02-13 Thread Kenny Li
Kent:   Overriding the accept() is an excellent idea. It looks more elegant than my original thinking of "total" subclassing. Thanks a lot; I have learned a great deal from you.   Kenny   On 2/13/06, Kent Johnson <[EMAIL PROTECTED]> wrote: Kenny Li wrote:> Yep! I think that is what I want. I did no

Re: [Tutor] Instantiate a subClass using an instance of its baseClass

2006-02-13 Thread Kent Johnson
Kenny Li wrote: > Yep! I think that is what I want. I did not know enough to do (inside > C.__init__() ): > arg1.__class__=C > > As to my intent, I want to subclass socket.socket. By doing so, I may > get a socket (instance of my baseClass) after it (my subclass) accepts > an incoming

Re: [Tutor] Instantiate a subClass using an instance of its baseClass

2006-02-13 Thread Kent Johnson
Kenny Li wrote: > Kent: > > I forgot to mention that no coping is allowed. Your two options > essentially are doing copying of the b. Not really. I make new references to the attributes of b. It sounds like you want c = C(b) to actually convert b to be an instance of C, instead of creating

Re: [Tutor] Instantiate a subClass using an instance of its baseClass

2006-02-13 Thread Kent Johnson
Kenny Li wrote: > *class B(object): * > *''' the baseClass '''* > *def __init__(self, arg1, arg2):* > *self.a1=arg1* > *self.a2=arg2* > * * > *class C(B): * > *''' C is subClass of B '''* > *def __init__(self, arg1, arg2):* > *B.__init__(self, ar

[Tutor] Instantiate a subClass using an instance of its baseClass

2006-02-12 Thread Kenny Li
Hi Tutor:   My question is "how to instantiate a subClass using an instance of its baseClass?"   Details below: =   class B(object):      ''' the baseClass '''     def __init__(self, arg1, arg2):     self.a1=arg1     self.a2=arg2   class C(B):     ''' C is subClass of B ''