monty.inspect module¶
Useful additional functions to help get information about live objects
- all_subclasses(cls)[source]¶
Given a class cls, this recursive function returns a list with all subclasses, subclasses of subclasses, and so on.
- caller_name(skip=2)[source]¶
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
- initializer(func)[source]¶
Automatically assigns the parameters. http://stackoverflow.com/questions/1389180/python-automatically-initialize -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')