loading
open in
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Animal:
  pass

class Cat(Animal):
  pass

def fun(val):
  if type(val) is int:
    print("It is an int!")
  elif type(val) is Animal:
    print("It is an animal!")
  else:
    print("Unknown type :(")

def fun2(val):
  if isinstance(val, int):
    print("It is an int!")
  elif isinstance(val, Animal):
    print("It is an animal!")
  else:
    print("Unknown type :(")

fun(1)
fun("Hello World")
fun(Animal())
fun(Cat())

fun2(1)
fun2("Hello World")
fun(Animal())
fun2(Cat())