Python vars() Function

❮ Built-in Functions


Example

Return the __dict__ atribute of an object called Person:

class Person:
  name = "John"
  age = 36
  country = "norway"

x = vars(Person)
Try it Yourself »

Definition and Usage

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

The __dict__ attribute is a dictionary containing the object's changeable attributes.

Note: calling the vars() function without parameters will return a dictionary containing the local symbol table.


Syntax

vars(object)

Parameter Values

Parameter Description
object Any object with a __dict__attribute

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.