A high-level library for Python object inspection


Keywords
objinspect, object, inspection, code, introspection, python, inspect, pretty, dir, debugging, development-tools, code-analysis, function-signature, inspect-type-hints, metaprogramming, object-inspection, python-inspect
License
Other
Install
pip install objinspect==0.2.5

Documentation

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

  • Simplified inspection of Python objects (classes, functions, methods)
  • Detailed information about parameters, return types, and docstrings
  • prettydir - like dir(), but with more information and prettier output

Installation

From PyPi

pip install objinspect

From source

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

Examples

>>> from objinspect import inspect, pdir
>>> 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=7, description='Inspects an object and returns a structured representation of its attributes and methods.')

prettydir

image

License

MIT License