Skip to content

pp should take keyword arguments like pprint #18

Description

@aluttik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions