On this page
  1. vars
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

vars

Prev: type | Up: __builtins__ | Next: zip
Rel: callable, delattr, dir, getattr, hasattr
Ref: docs.python.org — vars
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import vars

Overview & Signature

vars([object]) -> dictionary

Without arguments, equivalent to locals().

Usage

class User:
    def __init__(self, name: str) -> None:
        self.name = name

u = User("Ada")
assert vars(u) == {"name": "Ada"}

Gotchas

REPL Inspect

help(vars)

Linked from

Related notes