igrek51

wat: Inspect Python Objects at Runtime

wat is a Python inspection tool for exploring unfamiliar objects in a console or debugger. It displays values, types, attributes, methods, signatures, documentation, and available source code to support debugging and learning.

Stars
1.9k
Forks
32
Stars, last 8 days
+0

Our take

Health score

22/100

How it is scored
Activity
20
Community
27
Issues
21
Pull requests
21

+0 stars in the last 8 days

Overview

wat is a runtime inspector for Python objects. It helps developers answer “what is this object?” without manually combining introspection calls, especially when exploring unfamiliar libraries, complex values, or Python internals.

Use it interactively in a Python console or debugger, either with its compact wat / object syntax or as a function. It is intended for investigation and debugging, not as a replacement for an IDE debugger or static analysis tool.

Key Features

  • Displays an object's formatted value, type, and parent types.
  • Lists variables and methods, with signatures and documentation where available.
  • Can show source code for functions, methods, and classes when available.
  • Offers modifiers to shorten output, reveal dunder or private attributes, and control documentation and formatting.
  • Inspects local and global variables through wat.locals and wat.globals.
  • Provides multiple calling styles, including division syntax, function calls, and piping.
  • Installs without external dependencies, or can be loaded in a session using the documented Insta-Load snippet.

Use Cases

  • A Python developer debugging an unfamiliar return value can quickly identify its type and inspect its attributes.
  • Someone learning a library can review a function's signature and documentation from an interactive console.
  • A developer stopped at a debugger breakpoint can inspect local objects without leaving the session.
  • A Python learner exploring built-ins or complex collections can examine their types, structure, and available methods.

Getting Started

Install the package and import it:

pip install wat
import wat
wat / some_object

See the README for modifiers, examples, and alternative loading methods. Documentation is also available at igrek51.github.io/wat.

Considerations

  • Inspection is performed at runtime, so the object must be available in the current Python process.
  • Source code and documentation may not be available for every object.
  • The README's Insta-Load option executes decoded Python code. Review the extracted code before running it, as the project itself recommends.
  • The repository reports no external package dependencies; the tool is aimed at interactive inspection rather than automated analysis.

Found this useful?

Share it with someone who would like wat.