Is there any way to use pprint to format object to file or at least to string?
I know I can save a table with:
which is not very readable,
or as a json:
file = io.open(path, "w") file:write(json.encode(table)) file.close()
which is better but still in just one line.
It is much more space efficient without extra spaces I get it, but I want it to be still more readable. And since pprint does exactly what I need I am wondering whether there is any way to redirrect its output to file or at least to string.
I hoped the “pprint” it uses “print” to print so I overrode it but to my disappointment it seems it does not use it. :\
Thank you in advance.