Questions tagged [pretty-print]

Prettyprint (or pretty-print) is the application of any of various stylistic formatting conventions to text, source code, markup, and other similar kinds of content. These formatting conventions usually consist of changes in positioning, spacing, color, contrast, size and similar modifications intended to make the content easier for people to view, read and understand.

1047 questions
24
votes
3 answers

Prevent Visual Studio 2015 from removing line continuation characters (_) in VB.NET files

I'm opening some old VB.NET projects in Visual Studio 2015 and when I edit the code, VS changes the syntax: It removes "_" in concatenations: 'Before myString = "ABC" & _ "DEF" 'After myString = "ABC" & "DEF" or add a space…
24
votes
3 answers

pprint(): how to use double quotes to display strings?

If I print a dictionary using pprint, it always wraps strings around single quotes ('): >>> from pprint import pprint >>> pprint({'AAA': 1, 'BBB': 2, 'CCC': 3}) {'AAA': 1, 'BBB': 2, 'CCC': 3} Is there any way to tell pprint to use double quotes (")…
E.Z.
  • 6,393
  • 11
  • 42
  • 69
23
votes
0 answers

Algorithm for neatly indenting SQL statements (Python implementation would be nice)

I'd like to reformat some SQL statements that are a single string with newlines in to something that's much easier to read. I don't personally know of a good coding style for indenting SQL - how should nested queries / where clauses / left joins /…
Simon Willison
  • 15,642
  • 5
  • 36
  • 44
23
votes
5 answers

Pretty-print dataclasses prettier with line breaks and indentation

Python Data Classes instances also include a string representation method, but its result isn't really sufficient for pretty printing purposes when classes have more than a few fields and/or longer field values. Basically I'm looking for a way to…
maxschlepzig
  • 35,645
  • 14
  • 145
  • 182
23
votes
1 answer

How to prettyprint (human readably print) a Python dict in json format (double quotes)?

This is a follow-up question to this one. I need to both prettyprint a python dict (so I can visually inspect/modify it), and I need to have the output in json format (with the double quotes). pprint module prettyprints the dict but uses single…
travelingbones
  • 7,919
  • 6
  • 36
  • 43
23
votes
2 answers

PPRINT in Emacs Lisp?

Emacs Lisp does not seem to have a PPRINT function. How do you pretty print an S-EXP in elisp the way you can in Common Lisp?
anthonyf
  • 231
  • 2
  • 4
23
votes
3 answers

Pretty printing XML with Jackson library

I am trying to use Jackson library to serialize Java objects into XML by using JAXB annotations. However, I face an issue in pretty-printing the XML output. Here is my sample code usage: ObjectMapper mapper = new…
Buchi
  • 1,322
  • 4
  • 14
  • 33
23
votes
1 answer

How can I pretty-print XML source using VB6 and MSXML?

I've been looking after this for months now and I mostly found sites asking the same question. The answers I did found were always for .NET or C++ or involved XSLT.
Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
21
votes
4 answers

How can I make my class pretty printable in Python?

Python has a pretty printer (pprint(...)). I would like to make my classes pretty printable. Will pretty print print my instances in a better way, if I provide a certain interface? The Python documentation in section 8.11 shows different examples,…
Paebbels
  • 15,573
  • 13
  • 70
  • 139
20
votes
4 answers

How can OCaml values be printed outside the toplevel?

The OCaml repl ("toplevel") has rich printing for any types, user-defined or otherwise. Is it possible to access this functionality outside the toplevel, rather than having to write an entirely custom set of value printers for one's own entire set…
jrk
  • 2,896
  • 1
  • 22
  • 35
20
votes
5 answers

A list of useful Python commands for Vim?

I was looking for a quick way to autoformat/pretty-print JSON in Vim the other day and found this great little command on Stack Overflow: :%!python -m json.tool That sent me on a search for a list of other Python tools to pretty-print common web…
johnmdonahue
  • 653
  • 7
  • 16
20
votes
2 answers

C++ debug/print custom type with GDB : the case of nlohmann json library

I'm working on a project using nlohmann's json C++ implementation. How can one easily explore nlohmann's JSON keys/vals in GDB ? I tried to use this STL gdb wrapping since it provides helpers to explore standard C++ library structures that…
LoneWanderer
  • 3,058
  • 1
  • 23
  • 41
20
votes
2 answers

how to write dataframe in JSON in pretty print style?

I want to convert my dataframe to json and dump it in a file in a pretty print format. I tried - df.to_json(r'C:\users\madhur\Desktop\example.json,'orient = 'index') the above code is dumping in json but in a single line. I also tried import…
Madhur Yadav
  • 635
  • 1
  • 11
  • 30
20
votes
5 answers

How to pretty print a complex Java object (e.g. with fields that are collections of objects)?

I'm looking for a library function (ideally from a commonly used framework e.g. Spring, Guava, Apache Commons etc.) that will nicely print the values of any Java object. This is a general question rather than a specific one. Have seen similar…
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
20
votes
2 answers

pretty output with pyyaml

I have a python project where I'd like to use YAML (pyYaml 3.11), particularly because it is "pretty" and easy for users to edit in a text editor if and when necessary. My problem, though, is if I bring the YAML into a python application (as I will…
Mayur Patel
  • 945
  • 1
  • 7
  • 15