-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Consider integrating https://github.com/tommikaikkonen/prettyprinter #10953
Comments
Thanks @njsmith for the kind words! IPython is great, and I've been using
|
It does seem to run on 3.5, but there are small issues ( |
Good point. Python 3.5 users would have to use a different version of pretty_call_alt(ctx, sorted, args=([3, 6, 4], ), kwargs=[('reversed', True)])` to support ordered keyword arguments. It's not as simple as |
I'm supportive of the idea of having prettyprinter alternatives, but I would rather keep it on the level of having an extension point that's available for alternatives to what IPython provides by default, and being very conservative about changing that default because of how many people out there rely on IPython. But I'm just one person - and I realize there's a tension between keeping existing (grumpy-like-me) users happy by not changing things they are used to, and giving other users new reasons to make their experiences happier. |
This library is very young, but looks really excellent: https://tommikaikkonen.github.io/introducing-prettyprinter-for-python/
Compared to IPython's current pretty-printing system, this adds syntax-highlighting, what sounds like a better layout algorithm, and a much simpler system for customization.
For example, here's stock IPython:
And here's IPython with
prettyprinter
integration (i.e. monkeypatching) enabled (note that this uses a different set of highlight colors, whoops, but you get the idea):And here's the kind of hoop-jumping I had to do to integrate patsy with IPython's current pretty-printing system: https://github.com/pydata/patsy/blob/924b387652d13f816fd4a32983aae2ccba38fd84/patsy/util.py#L437-L454
That's a helper function to generate reprs like
Class(arg1, arg2, kwarg=something)
. I'm not sure anyone else ever took the trouble to actually implement this in their library. OTOH inprettyprinter
, this is available as a trivial built-in.I'm sure there are a number of obstacles here; off the top of my head:
prettyprinter currently requires 3.6+, while IIRC even the next release IPython will still support at least 3.5
there'd need to be some backcompat story for code that does use
_repr_pretty_
and all that (I guess? I don't know how much of this code is out there)there'd need to be some story about how this works in the notebook (does the notebook understand ANSI color? do we need an HTML output option?)
Does @tommikaikkonen actually want the responsibility of having Python's userbase descend upon their innocent little library
probably other things I'm missing
But I figured I'd at least raise the issue here so y'all were aware this existed and could at least start the conversation.
The text was updated successfully, but these errors were encountered: