Ticket #79 (closed enhancement: invalid)

Opened 3 years ago

Last modified 4 months ago

pretty print for dict and list

Reported by: olethanh Assigned to:
Priority: moderate Keywords:
Cc:

Description

It would be nice to have a pretty print for dict and list like ipython does

Change History

04/02/09 10:13:46 changed by akaihola

pprint.pformat() or pprint.pprint() might be useful for this.

04/02/09 13:45:30 changed by otaylor

I'd appreciate more detail about what is desired here - Reinteract already does something along the lines of pprint.format - see:

http://git.fishsoup.net/cgit/reinteract/tree/lib/reinteract/data_format.py

For very big lists and multi-dimension numpy arrays, you could imagine using a scrolling widget rather than dumping out a text representation, but obviously that's something that neither ipython nor pprint does.

04/04/09 07:38:39 changed by akaihola

I assume olethanh would like Reinteract to do such formatting by default. Here's an example of what IPython does:

In [1]: range(25)
Out[1]: 
[0,
 1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,
 14,
 15,
 16,
 17,
 18,
 19,
 20,
 21,
 22,
 23,
 24]

In [2]: dict.fromkeys(range(25))
Out[2]: 
{0: None,
 1: None,
 2: None,
 3: None,
 4: None,
 5: None,
 6: None,
 7: None,
 8: None,
 9: None,
 10: None,
 11: None,
 12: None,
 13: None,
 14: None,
 15: None,
 16: None,
 17: None,
 18: None,
 19: None,
 20: None,
 21: None,
 22: None,
 23: None,
 24: None}

Here's a worksheet for testing what Reinteract outputs by default and with data_format.format() plus pprint() output as a comparison:

from reinteract.data_format import format
from pprint import pprint

range(25)
dict.fromkeys(range(25)) 

print format(range(25))
print format(dict.fromkeys(range(25)))

pprint(range(25))
pprint(dict.fromkeys(range(25)))

04/04/09 11:21:40 changed by olethanh

Yes I was thinking about having this behaviour by default. The manual way isn't easily discoverable and doing it each time you want to see the value of a variable seems a bit tedious.

09/27/11 23:39:26 changed by otaylor

  • status changed from new to closed.
  • resolution set to invalid.

Moved to https://bugzilla.gnome.org/show_bug.cgi?id=660320, closing as "invalid"