vars()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jun 22, 2023
Contribute to Docs

vars() is a built-in Python function that returns the __dict__ attribute of an object. The __dict__ attribute is a dictionary containing the object’s mutable attributes.

Syntax

vars(object)

Here, object refers to an instance of a particular class.

Codebyte Example

The following example uses vars() to return the __dict__ attributes of the object Person:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy