The IPython console prints a list of elements with line breaks so that each element is displayed in its own line. This is usually a feature, but in my case it is a bug: I need to copy and paste long lists, so I need a compact representation. How can I achieve this?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can use
%pprint
command to turn on/off pprint feature:If you want to turn off
pprint
permanently, make a profile, and addc.PlainTextFormatter.pprint = False
to the profile file.Linux example:
An alternative to turning off pretty printing entirely is to increase the
max_width
trait for thePlainTextFormatter
.Add the following to
ipython_config.py
(find it byipython locate profile
):which will allow the pretty printer to use less vertical space by allowing lines to extend out to 120 characters rather than the default of 79.
Start
ipython
with--no-pprint
option.Another options is to start ipython with
--classic
option, in thatpprint
is already disabled: