On Thu, Jun 9, 2022 at 1:52 PM Michael F. Stemper <michael.stem...@gmail.com> wrote:
> On 09/06/2022 12.52, Chris Angelico wrote: > > On Fri, 10 Jun 2022 at 03:44, Dave <d...@looktowindward.com> wrote: > > >> Before I write my own I wondering if anyone knows of a function that > will print a nicely formatted dictionary? > >> > >> By nicely formatted I mean not all on one line! > >> > > > > https://docs.python.org/3/library/pprint.html > > > > from pprint import pprint > > pprint(thing) > > >>> from pprint import pprint > >>> d = {'two':2, 'three':5} > >>> pprint(d) > {'three': 5, 'two': 2} > >>> > > This is all on one line. That might be acceptable to the OP, but it > doesn't actually match what he said. > For small outputs, pprint uses a single line. For larger outputs, it inserts newlines. It's intended to be human-readable more than machine-readable. -- https://mail.python.org/mailman/listinfo/python-list