monty.inspect module

Useful additional functions to help get information about live objects


Given a class cls, this recursive function returns a list with all subclasses, subclasses of subclasses, and so on.


Get a name of a caller in the format module.class.method

skip specifies how many levels of stack to skip while getting caller name. skip=1 means “who calls me”, skip=2 “who calls my caller” etc.

An empty string is returned if skipped levels exceed stack height

Taken from:

Public Domain, i.e. feel free to copy/paste


This function inspects the Cpython frame to find the path of the script.


Automatically assigns the parameters. -instance-variables

>>> class process:
...     @initializer
...     def __init__(self, cmd, reachable=False, user='root'):
...         pass
>>> p = process('halt', True)
>>> p.cmd, p.reachable, p.user
('halt', True, 'root')