vars()
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
:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours