reset password
Author Message
rabbott
Posts: 1649
Posted 15:40 Apr 29, 2019 |

In class today we talked about classes and their relationship to types and objects. Try running this.

print(isinstance(type, type))      # => True
print(issubclass(type, type))      # => True
print(isinstance(type, object))    # => True
print(issubclass(type, object))    # => True

print(isinstance(object, type))    # => True
print(issubclass(object, type))    # => False
print(isinstance(object, object))  # => True
print(issubclass(object, object))  # => True

class C(type):
    pass

print(isinstance(C, type))         # => True
print(issubclass(C, type))         # => True
print(isinstance(C, object))       # => True
print(issubclass(C, object))       # => True

class D:
    pass

print(isinstance(D, type))         # => True
print(issubclass(D, type))         # => False
print(isinstance(D, object))       # => True
print(issubclass(D, object))       # => True