Built-in Functions and Types
vars()
Inspect an object’s __dict__ attribute when present. For ordinary instances this may be the mutable instance dictionary; classes expose a read-only mapping proxy. Objects without __dict__ raise TypeError. With no argument, vars follows locals(), including Python 3.13 snapshot behavior inside optimized scopes. It does not enumerate inherited attributes or every attribute stored in slots.
Formal Syntax & Structure
python syntaxpython
vars()vars(object, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| object | object with __dict__ | Optional object; omit to inspect current local bindings. |
Return Value
dict or mapping
Object namespace or current local namespace representation.
Working Example
Example Snippetpython
class Note: category = "work"
note = Note()note.title = "Review"print(vars(note))print("category" in vars(note))