Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

# formatting module

Utilities for formatting.

## format_array function

    format_array(
        array,
        tabulate=None,
        html=False,
        **kwargs
    )

Format an array.

Arguments are passed to `pd.DataFrame.to_string` or `pd.DataFrame.to_html` if `tabulate` is False, otherwise to `tabulate.tabulate`. If `tabulate` is None, will be set to True if the `tabulate` library is installed and `html` is disabled.

## format_func function

    format_func(
        func,
        incl_doc=True,
        **kwargs
    )

Format a function.

## format_parameter function

    format_parameter(
        param,
        annotate=False
    )

Format a parameter of a signature.

## format_signature function

    format_signature(
        signature,
        annotate=False,
        start='\n    ',
        separator=',\n    ',
        end='\n'
    )

Format a signature.

## pdir function

    pdir(
        *args,
        **kwargs
    )

Print the output of parse_attrs().

## phelp function

    phelp(
        *args,
        **kwargs
    )

Print the output of format_func().

## pprint function

    pprint(
        *args,
        **kwargs
    )

Print the output of prettify().

## prettify function

    prettify(
        obj,
        replace=None,
        path=None,
        htchar='    ',
        lfchar='\n',
        indent=0
    )

Prettify an object.

Unfolds regular Python data structures such as lists and tuples.

If `obj` is an instance of Prettified, calls Prettified.prettify().

## prettify_dict function

    prettify_dict(
        obj,
        replace=None,
        path=None,
        htchar='    ',
        lfchar='\n',
        indent=0
    )

Prettify a dictionary.

## prettify_inited function

    prettify_inited(
        cls,
        kwargs,
        replace=None,
        path=None,
        htchar='    ',
        lfchar='\n',
        indent=0
    )

Prettify an instance initialized with keyword arguments.

## ptable function

    ptable(
        *args,
        display_html=None,
        **kwargs
    )

Print the output of format_array().

If `display_html` is None, checks whether the code runs in a IPython notebook, and if so, becomes True. If `display_html` is True, displays the table in HTML format.

## Prettified class

    Prettified()

Abstract class that can be prettified.

Subclasses

- Configured
- pdict

### prettify method

    Prettified.prettify(
        **kwargs
    )

Prettify this object.

Warning

Calling prettify() can lead to an infinite recursion. Make sure to pre-process this object.

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings