Python – Find __dict__ Attribute of Class – vars() Function with Examples

vars() function is used to find the the __dict__ attribute of the given object if the object has __dict__ attribute in Python for the given input.

vars() function is a part of Python Built-in Functions.

Syntax of vars() Function

The syntax of vars() function in Python is:

 

Parameters of vars() Function in Python

x – Where x is any valid . This parameter is required.

 

Compatibility

vars() function is available and compatible with both Python 2.x and 3.x.

 

Return Value of vars() Function in Python

vars() function returns the __dict__ attribute of the given object if the object has __dict__ attribute for the given input.

 

Python vars() Function Example 1


Output:

 

Python vars() Function Example 2


Output: