R
Richard Gruet
Hi all,
How to determine that an object o is for sure an instance of a new-style
class, without knowing of which specific class ?
That is, if I define a function:
def isNewStyleClassInstance(o):
pass ## to be completed
... I want to pass the following test:
def C: pass
def CNew(object): pass
assert not isNewStyleClassInstance(C()) # InstanceType
assert isNewStyleClassInstance(CNew())
assert not isNewStyleClassInstance(1) # instance of type int
# and naturally for all other types of o the function should return False.
Richard
How to determine that an object o is for sure an instance of a new-style
class, without knowing of which specific class ?
That is, if I define a function:
def isNewStyleClassInstance(o):
pass ## to be completed
... I want to pass the following test:
def C: pass
def CNew(object): pass
assert not isNewStyleClassInstance(C()) # InstanceType
assert isNewStyleClassInstance(CNew())
assert not isNewStyleClassInstance(1) # instance of type int
# and naturally for all other types of o the function should return False.
Richard