FAQ Database Discussion Community


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

python,logging,file-writing,pprint
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 the code...

How to indent with pprint in Python?

python,indentation,pretty-print,pprint
I am trying to indent the output of pprint so that I will get an 8 space indentation with pprint. The code I used is: import numpy as np from pprint import pprint A = np.array([1, 2, 3, 4]) f = open("log.txt", 'w') n = 2 for i in range(n):...

write() file by inserting dict in specific key order and format

python,pprint
I need to create a file, and insert a dictionary in it. The dictionary has to: be in a format like pprint(). have keys ordered in a specific way. I know i can simply use with open() and insert everything in a specific order with some custom-made function... with open('Dog.txt',...

How to log which is the Pretty print like pprint by clojure.tools.logging?

logging,clojure,pprint
I am using org.clojure/tools.logging. I want to get a function which can pretty print the log, but I can't find it. For example, the content which i want to print is {:status 401, :headers {"Content-Type" "application/octet-stream"}, :body {:error "You don't login."}} but i call the function name is info,I get...