# Introspection (inspect)

say it: **“in-truh-SPEK-shun”** **/ˌɪntrəˈspɛkʃən/** or **“in-SPEKT”** **/ɪnˈspɛkt/**

A program looking at itself while it runs: types, attributes, function arguments.

## What is **introspection**?

**Introspection** is a program looking at itself while it runs: what type something is, what attributes it has, what arguments a function takes. The `inspect` module helps.

```python
import inspect

def book_room(city, nights=1):
    pass

print(inspect.signature(book_room))  # (city, nights=1)
print(hasattr("hello", "upper"))      # True
```

Level: Master · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=5)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/introspection-inspect
