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
0
votes
1 answer

Python formatting my json output

# -*- coding: utf-8 -*- import json from pprint import pprint drink_list = [23,601,633,673,607,662,6622,6014,6104,615,038,606,607,627,6094] filename = (r'C:\Users\desktop\pizza\123template.json') with open(filename, 'r') as f: data =…
the hank
  • 15
  • 5
0
votes
2 answers

Printing a list vertically with pprint

I try to use pprint to print a list: >>> import pprint >>> a = [1, 3, 6, 8, 0] >>> pprint.pprint(a) [1, 3, 6, 8, 0] >>> why not this [1, 3, 6, 8, 0] look forward you answer! THANKS!
0
votes
1 answer

pprint dictionary returned as unicode

I am using requests module. And, the data returned is unicode which contains the response(dictionary) from a server. Is there a way to pretty print the unicoded dictionary? This response returned looks like…
Aditya
  • 551
  • 5
  • 26
0
votes
1 answer

python pretify list output like numpy or pandas does

How can I style text like numpy or pandas does? I tried using pprint, but it either was not what I was expecting. Let's say I have a list [[0 for w in range(1000)] for h in range(1000)]. I would like to print it similar to this: From pandas: …
Zloutek1
  • 55
  • 6
0
votes
1 answer

Ignore capitalization when ordering dict using pprint?

So I have a dictionary, say: myDict = {"145":1, "Kittens":2, "apples":1, "trees":2} and using pprint(myDict, ...), I get: {'145': 1, 'Kittens': 2, 'apples': 1, 'trees': 2} Instead, I'd like to ignore the capital K's apparent order priority and…
Luke McPuke
  • 354
  • 1
  • 2
  • 12
0
votes
1 answer

Lihaoyi PPrint Deep Tree

title: Lihaoyi PPrint Deep Tree link: Lihaoyi PPrint Deep Tree I have a "deep" tree of case classes that I want to pprint as "like Scala" source code. ... because I want to view, copy and paste them to make a UnitTest I am using lihaoyi's pprint…
pal
  • 942
  • 1
  • 9
  • 19
0
votes
1 answer

Print the head (first few lines) of a pretty-print representation of an object

I'm running Python 2.7 in a Jupyter notebook. I am working with large nested dictionaries, and sometimes it's helpful to print out one of these. Using pprint.pprint is a nice way of getting a readable version of the dict on screen. But for…
LangeHaare
  • 2,776
  • 2
  • 17
  • 25
0
votes
0 answers

View the complete args string while using pdb?

I need to view the complete string in the Argparse object args.networkModel Original code is from https://github.com/cmusatyalab/openface/blob/master/demos/classifier.py I only have access to the pdb in the terminal. When I try the…
Arsenal Fanatic
  • 3,663
  • 6
  • 38
  • 53
0
votes
0 answers

Outputting Python To Word Document

I've been following along in Automate the Boring Stuff. This question follows my two previous questions here: Iterate a Nested Dictionary in Python Iterate Dictionary in Python and Sum Totals by Category I've been using the methods used in ATBS to…
John Rogerson
  • 1,153
  • 2
  • 19
  • 51
0
votes
1 answer

How to print query result in python/django

I came from CakePHP and just started playing with Django framework. In CakePHP, I have the habit of printing out all the returned array using pr() straight out to the webpage. For example: A controller spits out a $result to a View, I use…
H Bui
  • 63
  • 1
  • 7
0
votes
1 answer

Run time call within pprint

How to pass value inside pprint at run time? import nltk, sys from pprint import pprint from nltk.corpus import framenet as fn #Word = raw_input("enter a word: ") pprint(fn.frames(r'(?i)Medical_specialties')) f =…
Programmer_nltk
  • 863
  • 16
  • 38
0
votes
1 answer

Python Highlight specific text in json document on terminal

I am interested in highlighting a specific portion of the json document based on some arbitrary matching algorithm. For example { "text" : "hello world" } I searched for "hello" and above json document has hello in it. How to highlight that…
hello world
  • 660
  • 2
  • 6
  • 25
0
votes
1 answer

How to pprint globals() in a loop (that has another write log command) at end of file?

I am trying to create a log file that receives variable information using pprint globals() and writes to file. But since I have to use many loops, is there a way to place all the pprint globals() output during each loop at the end of log file for…
Tom Kurushingal
  • 6,086
  • 20
  • 54
  • 86
0
votes
1 answer

Write UTF-8 strings to file with pprint

I would like to write dictionaries with UTF-8 strings to a file. I saw another thread about printing utf-8 strings with pprint, and tried to modify the code seen there like this MyPrettyPrinter().pprint(dict, stream=f) but it is not working. I have…
Rolf
  • 331
  • 4
  • 13
0
votes
1 answer

Filter return results printed in text file python

Using this code: from pysnap import Snapchat from pprint import pprint s = Snapchat() username = raw_input('Enter your username: ') password = raw_input('Enter your password: ') s.login(username, password) friends = s.get_friends() newfile =…
Snowlav
  • 325
  • 1
  • 12
  • 26