You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
335 B
24 lines
335 B
# inheritance
|
|
|
|
class A:
|
|
def a():
|
|
print('A.a() called')
|
|
|
|
class B(A):
|
|
pass
|
|
|
|
print(type(A))
|
|
print(type(B))
|
|
|
|
print(issubclass(A, A))
|
|
print(issubclass(A, B))
|
|
print(issubclass(B, A))
|
|
print(issubclass(B, B))
|
|
|
|
print(isinstance(A(), A))
|
|
print(isinstance(A(), B))
|
|
print(isinstance(B(), A))
|
|
print(isinstance(B(), B))
|
|
|
|
A.a()
|
|
B.a()
|
|
|