vars() — Easy Examples
Returns the __dict__ attribute of an object
Basic vars() usage
Simple demonstration of the vars() built-in function.
python
class Point: def __init__(self, x, y): self.x = x self.y = y p = Point(1, 2) print(vars(p))
vars() is a built-in function that returns the __dict__ attribute of an object.
vars() with different inputs
Calling vars() with various argument types.
python
# More vars() examples print("vars() is a Python built-in function") print(f"Type: {type(vars)}")
vars() accepts different types of arguments and produces corresponding results.
Want to try these examples interactively?
Open Easy Playground