Python vars() Function

Instance

Returns the __dict__ attribute of the object named Person:

class Person:
  name = "Bill"
  age = 19
  country = "USA"
x = vars(Person)

Running Instance

Definition and Usage

The vars() function returns the __dict__ attribute of the object.

The __dict__ attribute is a dictionary containing the mutable attributes of the object.

Note:Calling vars() function without parameters returns a dictionary containing the local symbol table.

Syntax

vars(object)

Parameter Value

Parameter Description
object Any object with a __dict__ attribute.