What kind of class does my instance belong too?
Peter Stöhr
peter.stoehr at fh-hof.de
Mon Nov 13 13:13:56 EST 2000
Hi out there in the python-universe,
I'm having a small problem and after looking at the docs I was not able
to solve it by myself. So maybe someone out there can help me.
Lets assume I have create a class Spam and a class Eggs derived form
class Spam.
In one of the methods I have to implement a behaviours depending on
whether a passed instance is an instance of class Spam or something
different, for example:
class Spam:
...
class Eggs(Spam):
def doSomething(self, aArg):
if aArg is instance of Spam:
self.spamIt()
else:
seld.doSoemthingDifferent()
What I try to figure out is what is the correct way to write such an
if-statement ?
I've tried the builtin function type(). The result <type 'instance'> is
correct bit doesn't solve my problem :-(
Thanks in advance
Peter
More information about the Python-list
mailing list