pytools

File Purpose: tools whose main purpose is to work with implementation details of Python.

E.g. manipulate function docstrings

Functions

_inputs_as_dict__maker(callable_)

returns a function which returns dict of all inputs all inputs to callable_.

displaysource(obj, *[, module])

display sourcecode for obj, including syntax highlighting.

format_except_missing(s, **kw)

return s.format(**kw) but ignoring any missing keys.

format_replace_missing(s, replacement, **kw)

return s.format(**kw) but replace any missing keys with replacement.

has_exception_cause_in_chain(err, err_type)

returns whether error is an instance of err_type or was raised

help_str(f, *[, module, blankline, ...])

return str for help(f).

indent_doclines(s[, indent])

return string s, prepending all lines except line 0 with indent

indent_paramdocs(d[, indent])

return dict but with indent_doclines called on all the values.

inputs_as_dict(callable_, *args, **kw)

returns dict of all inputs to callable_ based on its signature and args & kwargs.

is_iterable(obj)

returns whether obj is iterable.

pad_missing_format_keys(s, keys)

return s (a format string) with all missing keys padded with extra {}.

print_help_str(f, **kw_help_str)

print help_str(f, **kw_help_str).

printsource(obj, *[, module, as_str])

prints source code for object (e.g. call this on a function or class).

replace_missing_format_keys(s, keys, replacement)

return s (a format string) with all missing keys replaced by replacement.

value_from_aliases(*aliaslist, **aliasdict)

returns the single provided value from aliases.