PythonBuilt-invars
getattr

varsBuilt-in

dir

Returns the __dict__ attribute of an object.

Syntax

vars(object?)

Example

Enter values below to update the example in real time.

class
Point
def
__init__
self
print
vars
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

p = Point(1, 2)
print(vars(p))  # {'x': 1, 'y': 2}