Can you explain what is metaclass and inheritance in Python?


Every class is an object. It's an instance of something called a metaclass. The default metaclass is typed. You can check this using the is instance function. For example,

class Foo:
   pass

foo = Foo()
isinstance(foo, Foo)
isinstance(Foo, type)

This will give the output:

True
True

A metaclass is not part of an object's class hierarchy whereas base classes are. These classes are used to initialize the class and not its objects.

You can read much more in-depth about Metaclasses and inheritance on https://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 17-Jun-2020

485 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements