beeprint icon indicating copy to clipboard operation
beeprint copied to clipboard

pp should take keyword arguments like pprint

Open aluttik opened this issue 9 years ago • 1 comments

It'd be nice to be able to set settings for pp with keyword arguments instead of using a new Config instance when we want to use it differently.

Perhaps something like:

def pp(o, output=True, max_depth=None, config=None, indent=None, width=None, sort_keys=None):
    """print data beautifully
    """

    config = config or Config()
    if max_depth is not None:
        config.max_depth = max_depth

    if indent is not None:
        assert indent >= 0
        config.indent_char = u' ' * indent

    if width is not None:
        assert width >= 0
        config.string_break_width = width

    if sort_keys is not None:
        config.dict_ordered_key_enable = bool(sort_keys)

    ...

Ideally, it'd be better to include the default arguments instead of just None, but first you'd need to address the bug #17

aluttik avatar Sep 19 '16 06:09 aluttik

Supported already?

pp(o, instance_repr_enable=False, max_depth=2)

abitrolly avatar Nov 14 '21 22:11 abitrolly