Skip to main content

A high-level library for Python object inspection

Project description

objinspect

Tests Documentation Status PyPI version Supported versions Downloads Downloads license

objinspect is a high-level wrapper around Python's built-in inspect module. It provides a simple interface for examining Python functions and classes.

Features

  • Inspect functions, methods, and classes with a consistent API
  • Access signatures, parameters, return annotations, and docstrings
  • prettydir (alias: pdir) for a richer dir()-style view

Installation

From PyPI

pip install objinspect
uv add objinspect

From source

pip install git+https://github.com/zigai/objinspect
uv add git+https://github.com/zigai/objinspect

Examples

>>> from objinspect import inspect
>>> import math
>>> inspect(math.pow)
Function(name='pow', parameters=2, description='Return x**y (x to the power of y).')

>>> inspect(math.pow).dict
{
   'name': 'pow',
   'parameters': [
      {'name': 'x', 'kind': <_ParameterKind.POSITIONAL_ONLY: 0>, 'type': <class 'inspect._empty'>, 'default': <class 'inspect._empty'>, 'description': None},
      {'name': 'y', 'kind': <_ParameterKind.POSITIONAL_ONLY: 0>, 'type': <class 'inspect._empty'>, 'default': <class 'inspect._empty'>, 'description': None}],
   'docstring': 'Return x**y (x to the power of y).'
}

>>> inspect(inspect)
Function(name='inspect', parameters=8, description='Inspects an object and returns a structured representation of its attributes and methods.')

prettydir

image

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

objinspect-1.0.0.tar.gz (77.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

objinspect-1.0.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file objinspect-1.0.0.tar.gz.

File metadata

  • Download URL: objinspect-1.0.0.tar.gz
  • Upload date:
  • Size: 77.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for objinspect-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f25f42bd50ebec97243c42950799b012bcea0581e41f91d2def1bc28530b593d
MD5 2e17effe06946c86cf8afdb24ce15ce3
BLAKE2b-256 6cfe0ede4296c0e7c565f7d032394b0ad205e11ffa49b45f42faa619c151ac75

See more details on using hashes here.

File details

Details for the file objinspect-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: objinspect-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for objinspect-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ee2fbecd32f011bed974cfd97783f27cf104d220c77150c6d1ba8910b31e45d
MD5 ad85994e5137c2f21ba5c44e897e947e
BLAKE2b-256 98b93aaf89f78a5a7ca4f8a73a7fba180e76012215ef45e46c1c416d1a524ac8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page