Hy pretty printer¶
hy.contrib.pprint
is a port of python’s built-in pprint
that can pretty
print objects using Hy syntax.
=> (pprint {:name "Adam" :favorite-foods #{:apple :pizza}
:bio "something very important"}
:width 20)
{:name "Adam"
:bio (+ "something "
"very "
"important")
:favorite-foods #{:apple
:pizza}}
Hy pprint
leverages hy-repr
for much of it’s pretty printing and
therefor can be extended to work with arbitrary types using
hy-repr-register
. Like Python’s pprint
and hy-repr
, Hy pprint
attempts to maintain round-trippability of it’s input where possible. Unlike
Python, however, Hy does not have string literal concatenation,
which is why strings and bytestrings are broken up using the form (+ ...)
.
The API for Hy pprint
is functionally identical to Python’s pprint
module, so be sure to reference the Python pprint
docs for more on how to use the module’s various methods and arguments.
The differences that do exist are as follows:
isreadable
becomesreadable?
isrecursive
becomesrecursive?
- Passing
False
to thePrettyPrinter
argsort-dicts
in Python versions < 3.8 will raise aValueError