Python - Check Instance class link with __class__

Introduction

To do inheritance search on attribute fetches, each instance has a link to its class.

It's called __class__:

Demo

class rec: pass              # Empty namespace object 
rec.name = 'Bob'             # Just objects with attributes 
rec.age  = 40 #  w  ww .j a  v a 2  s  . c  om

d = rec.__class__            # Instance to class link 
print( d )

Result

Related Topic