Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.92 KB

README.rst

File metadata and controls

54 lines (40 loc) · 1.92 KB

CircleCI Travis Appveyor Codecov Pypi Downloads ReadTheDocs

Tools for static and dynamic code introspection.

Helps with writing doctests

def func(a=1, b=2, c=3):
    """
    Example:
        >>> from this.module import *  # import contextual namespace
        >>> import xinspect
        >>> globals().update(xinspect.get_func_kwargs(func))  # populates globals with default kwarg value
        >>> print(a + b + c)
        6
    """

Helps with code that generates code

>>> import ubelt as ub
>>> source = ub.codeblock(
>>>     '''
>>>     p = os.path.dirname(join('a', 'b'))
>>>     glob.glob(p)
>>>     ''')
>>> # Generate a list of lines to fix the name errors
>>> lines = autogen_imports(source=source)
>>> print(lines)
['import glob', 'from os.path import join', 'import os']

See Also: https://github.com/Erotemic/xdev