What is the purpose of subclassing an instance of a class in Python? Here's an example:
class A:
def __init__(*args): print(args)
base = A()
class Test(base): pass
This code works properly under Python, but base
is an instance of class A
(1) Why do we need to subclass an instance of a class? Is it related to metaclasses?
From this question: What happens when you inherent from a module instead of a class in Python?
I understand that Test(base)
will become type(base).__init__
, (2) does this happen at definition time, when the class is defined? (3) How does Python know/decide that base
is an instance of a class? Is it becuase type(base)
doesn't return type
?