-1

I have written the following code.

class Mammal:
    def info():
        return 'I have fur on my body.'

    def identity_mammal():
        print('I am a mammal')

class Primate(Mammal):
    def info():
        return Mammal.info() + ' I have a large brain.'

    def identity_primate():
        print('I am a primate')

class Ape(Primate):
    def info():
        return Primate.info() + ' I am monkey oooh oooh aaah aaah.'

    def identity_ape():
        print('I am an ape')

class Human(Primate):
    def info():
        return Primate.info() + ' I am human, me bipedal SMART monkey'

    def identity_human():
        print('I am a human')

John = Human

print(isinstance(John, Mammal))
print(isinstance(John, Primate))
print(isinstance(John, Human))
print(isinstance(John, Ape))

It is a simple task about inheritance, but when i use the isinstance function, it doesn't seem like the instance of Human i just created is human

[iveris@ic-rh7mnifi-105 oblig44]$ python3 inheritance.py 

False
False
False
False

Iscariot
  • 11
  • 5

1 Answers1

1

To create the instance, you need to use parenthesis:

John = Human()

print(isinstance(John, Mammal))
print(isinstance(John, Primate))
print(isinstance(John, Human))
print(isinstance(John, Ape))
ronkov
  • 1,263
  • 9
  • 14
  • but using `John = Human`, and writing `print(John.info())`, I get `I have fur on my body.... etc` printed. Adding a parenthesis when declaring John, does make isinstance work, but makes `print(John.info())` give me an error – Iscariot Oct 29 '20 at 19:50