what is the meaning of metaobject? And why object is returned at last in the tuple returned by mro. what is the significance of that object?
Meaning of metaobject
A metaclass in Python is a class of a class that defines how a class behaves. Usually the tuple represents the path taken to reach the data.
Eg-
class A:
def rk(self):
print(" In class A")
class B:
def rk(self):
print(" In class B")
# classes ordering
class C(A, B):
def __init__(self):
print("Constructor C")
r = C()
# it prints the lookup order
print(C.__mro__)
output-
(<class ‘main.C’>, <class ‘main.A’>, <class ‘main.B’>, <class ‘object’>)
sir i didn’t got the meaning of class of class. can u plz give an example of its working. And regarding mro i understood that it is giving us the path of search like searching in i understand it will search in class B but i am not able to understand searching in <class ‘object’> what it means?
A Class is like an object constructor, or a “blueprint” for creating objects.That’s why object is written there.
As classes define the working of an object in the same way meta classes defie the working of objects , hence it is called class of class
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
"As classes define the working of an object in the same way meta classes defie the working of objects " it should be working of classes na ? and also how meta classes are declared?