Questions tagged [pprint]

Pprint is a Python module used for “pretty-printing” arbitrary data structures.

The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the interpreter.

136 questions
1
vote
2 answers

Inconsistent printing of nested dict using pprint in Python

I used pprint to pretty print a large nested dict: import pprint import json with open('config.json', 'r') as fp: conf = fp.read() pprint.pprint(json.loads(conf)) {u'cust1': {u'videotron': {u'temperature': u'3000K', …
m-ric
  • 5,621
  • 7
  • 38
  • 51
1
vote
1 answer

Look alternative to pprint for printing in Python

As we know, pprint can be "annoying" when it's printing list of a lot of small words, since pprint can only accept of two modes: one-line of multiple small words, or multiple lines of small words on each line separately. Is there some other python…
Nan Hua
  • 3,414
  • 3
  • 17
  • 24
1
vote
6 answers

Pretty print in Oracle PL/SQL

Is there a better way to print to STDOUT in Oracle PL/SQL? DBMS_OUTPUT.PUT_LINE seems very basic and coarse. Should there be something like Python's pprint (Pretty Print)?
olekb
  • 638
  • 1
  • 9
  • 28
1
vote
1 answer

Using pprint for OrderedDicts when dict is made with two lists

When I have OrderedDict created from two list and if I try to use pprint it's not working as expected, bur it works fine if I create OrderedDict normally. Any additional steps needs to be taken to get expected output of each key value in separate…
oneday
  • 629
  • 1
  • 9
  • 32
1
vote
1 answer

How to render large parenthesis correctly in sympy?

I am trying to render simple algebraic expressions in either qtconsole or a terminal using pprint, but the results are almost misleading. Here's a minimal example from sympy import pprint, simplify, init_printing from sympy.abc import a,…
1
vote
1 answer

how to print a Python dictionary in columns

Let's say I have a dictionary like the following: dictionary1 = { "Scientology": { "source": "LRH", "scilon 1": { "name": "John Travolta", "OT level": 5, "wall of fire": True }, …
d3pd
  • 7,935
  • 24
  • 76
  • 127
1
vote
3 answers

Output list like ls

Same question as this, but for python. If I have a list ['a','b','cdefg','jk','lmnopqr','st','uv','wxyz',1,2,3,4] I would like to print it something like the default output of the ls command in bash, something like [ 'a', 'b', 'cdefg', …
hawkjo
  • 400
  • 2
  • 11
1
vote
4 answers

python how to align data with pprint or another module

I've a python script who display data in realtime(each second). I want to align these. I've try with pprint module but it doesnt works. Example: My script displays this: Server1 Sessions/s-----------------------Server2 Sessions/s 64 …
Matt
  • 4,309
  • 7
  • 38
  • 52
0
votes
1 answer

How to pprint custom collection

I am not able to simulate pprint on my custom collections. See the following behaviour: >>>from pprint import * >>>pprint(["x"*80]*4) ['xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', …
BorjaEst
  • 390
  • 2
  • 11
0
votes
1 answer

Why did I get ModuleNotFoundError?

I tried the following code to import pprint from pprint module like import matplotlib.pyplot as plt. But I got an error instead. Why did I get this error? import pprint.pprint as…
Rama
  • 45
  • 6
0
votes
0 answers

Python pprint flush stdout per invocation

Is there a way to flush the stdout of pprint on a single invocation? I know we can start the interpreter unbuffered, with e.g. python -u, but I really just want this behavior for a one-time call.
flow2k
  • 3,999
  • 40
  • 55
0
votes
0 answers

can self.left be recognized as a variable in pformat({f"{self.value}": (self.left, self.right)}, indent=1)?

I use the codes below to print the structure of a tree. It do works, but I wonder in the last line how it recognize self.left and self.right as a variable rather than just a string? In my knowledge, variable should be enclosed by {} in f-string, but…
TomWu
  • 1
  • 1
0
votes
1 answer

Pretty print sympy when not using iPython

I am using SymPy with PyScript so I cannot use init_printing() in my code as I am not running code cell by cell. How can I still use pprint to make my output look good in Web? Output I am getting: Output I am expecting:
0
votes
2 answers

Wrap HTML tags around pretty-printed Clojure forms

Clojure's pretty printer (clojure.pprint) takes unformatted code like this: (defn fib ([n] (fib n 1 0)) ([n a b] (if (= n 0) a (fib (dec n) (+ a b) a)))) And makes it nice, like this. (defn fib ([n] (fib n 1 0)) ([n a b] (if (= n 0) …
0
votes
1 answer

pm4py printing event logs pretty (with pprint library)

I'm currently getting started with the pm4py library by playing around with some event logs. I have an example log that I'm importing like this: from pm4py.objects.log.importer.xes import importer as xes_importer log =…
beckersense
  • 310
  • 2
  • 12