On this page
  1. type
  2. Import & Availability
  3. Overview & Signature
  4. Common Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

type

Prev: tuple | Up: __builtins__ | Next: vars
Rel: bool, int, float, complex, str, Python Object, MRO & Initialization Dunder Flow
Ref: docs.python.org — type
Tags: #public #python3 #builtins


Import & Availability

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

Overview & Signature

type(object) -> the object's type

type(name, bases, dict, **kwds) -> a new type

Common Methods & Attributes

Usage

assert type(42) is int
# 3-argument form dynamically creates a new class: type(name, bases, namespace)
Point = type("Point", (), {"x": 0, "y": 0})
assert Point().x == 0

Gotchas

REPL Inspect

help(type)

Linked from

Related notes