Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pp should take keyword arguments like pprint #18

Open
aluttik opened this issue Sep 19, 2016 · 1 comment
Open

pp should take keyword arguments like pprint #18

aluttik opened this issue Sep 19, 2016 · 1 comment

Comments

@aluttik
Copy link

aluttik commented Sep 19, 2016

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

@abitrolly
Copy link

Supported already?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants