Constructing an object from another subclass of the same parent?

Nick Arnett narnett at mccmedia.com
Wed Apr 24 22:30:15 EDT 2002


I think that the answer to this is somewhere in a part of my brain that's
off-line at the moment (long day)... but I'm having trouble even composing a
reasonable search for the answer.

I can't remember how to construct an object that is a subclass of the parent
of the subclass I'm in.

E.g.,

class knight:
	blah, blah

class french(knight):
	blah, blah in your general direction

class english(knight):
	joker=french('Renee')

Neither the stuff above nor self.french('Renee') work, which really didn't
surprise me, since they shouldn't, but what should?

Something really awful along the lines of importing the module I'm in came
to mind.

And in case anyone cares, the parent's main purpose is to open a database,
create a handle and give me some methods for shortcuts to run certain types
of queries.  It has various subclasses that perform operations on the
database.  And now one of them needs one of the others.  Usually by the time
I've asked a question this clearly, the answer is equally clear and I throw
away the message... but apparently this one will actually survive.

Thanks... and surely it's time to quit for the day.

Nick

--
narnett at mccmedia.com
(408) 904-7198






More information about the Python-list mailing list