Skip to content
Built-in Functions

vars()

Get an object's attribute dictionary when it has one.

vars(object=None)

vars() returns the dictionary that stores an object's attributes.

With no argument, it returns the current local namespace.

Parameters

NameDescription
objectOptional object whose attribute dictionary you want.

Returns

A dictionary of attributes or local names.

Try it

Run it and change it
class Box: pass
box = Box()
box.colour = "blue"
print(vars(box))

Related entries