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

bpython could pprint by default #34

Closed
ikanobori opened this issue Jul 4, 2014 · 5 comments
Closed

bpython could pprint by default #34

ikanobori opened this issue Jul 4, 2014 · 5 comments

Comments

@ikanobori
Copy link
Contributor

@ikanobori ikanobori commented Jul 4, 2014

It would be nice if bpython could pprint the output by default. In an interactive interpreter, pretty printing things is much better, than the default printing.

Of course, this could be configurable for people that don't like pretty things. :)


@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

Thank you for the workaround.

Interactive shells are typically used for exploration or debugging. Debugging typically involves poring over large amounts of structured data. One good reason to be using bpython instead of ipython is because bpython supports invocation with app args (as it is intended to be a simple replacement for the python REPL), and ipython does not. The workaround could be added to my code, but part of the point of using a tool beyond the normal python REPL is useful extra functionality.

Closing feature requests on open source projects is bad form, unless it's reasonable to say "this feature will never enter the codebase, as it not feasible or conflicts with the purpose of the project". This feature appears to be neither impossible or against the goals of bpython.


Original Comment By:

@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

@Trundle This works, except when -i option is used to load a script file for interactive development/testing. would appreciate a better solution.


Original Comment By:

@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

Bump!


Original Comment By: Jose Quesada

@ikanobori ikanobori closed this Jul 4, 2014
@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

This can be easily done with a startup file. bpython executes, just like vanilla python, the content of the file identified by the //PYTHONSTARTUP// environment variable. So, creating a file containing

{{{
import builtin
import sys
from pprint import pprint

def displayhook(value):
if value is not None:
builtin._ = value
pprint(value)
sys.displayhook = displayhook
}}}

and setting //PYTHONSTARTUP// to it will work fine. Therefore, I do not see a reason to force that into bpython because users can easily customise bpython themselves if they want to. Perhaps we should mention that in the documentation or create some kind of //"tips & tricks"// wiki page.


Original Comment By: Andreas Stührk

@vdboor
Copy link

@vdboor vdboor commented Jun 22, 2015

Sadly it took me some effort to get this to work. I don't see why BPython can't offer a convienience setting for this, instead of having to work through Python Internals. IPython does offer it:

$ ipython help notebook | grep pprint -A1
--pprint
    Enable auto pretty printing of results.
--
--no-pprint
    Disable auto auto pretty printing of results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.