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 # from  w w w .  ja  va2 s. co m

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

Result

Related Topic