Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Dan Stromberg
On Thu, Jun 9, 2022 at 1:52 PM Michael F. Stemper wrote: > On 09/06/2022 12.52, Chris Angelico wrote: > > On Fri, 10 Jun 2022 at 03:44, Dave wrote: > > >> Before I write my own I wondering if anyone knows of a function that > will print a nicely formatted dictionary? > >> > >> By nicely

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Grant Edwards
On 2022-06-09, Dennis Lee Bieber wrote: > However, the Gmane list<>NNTP gateway server DOES make the tutor > list available to news readers (unfortunately, the comp.lang.python > <> list <> Gmane has been read-only since last fall (unless things > have changed recently) so I'm stuck with the

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Cameron Simpson
On 09Jun2022 21:35, Dave wrote: >I quite like the format that JSON gives - thanks a lot! Note that JSON output is JavaScript notation, not Python. The `pprint` module (which has `pprint` and `pformat` functions) outputs Python notation. If you're just writing for human eyes, JSON is fine,

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Michael F. Stemper
On 09/06/2022 12.52, Chris Angelico wrote: On Fri, 10 Jun 2022 at 03:44, Dave 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!

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Friedrich Rentsch
If you want tables layed out in a framing grid, you might want to take a look at this: https://bitbucket.org/astanin/python-tabulate/pull-requests/31/allow-specifying-float-formats-per-column/diff Frederic On 6/9/22 12:43, Dave wrote: Hi, Before I write my own I wondering if anyone knows

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Dave
Hi, I quite like the format that JSON gives - thanks a lot! Cheers Dave > On 9 Jun 2022, at 20:02, Stefan Ram wrote: > > Since nicety is in the eyes of the beholder, I would not > hesitate to write a custom function in this case. Python > has the standard modules "pprint" and "json". > >

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Mats Wichmann
On 6/9/22 11:52, Chris Angelico wrote: > On Fri, 10 Jun 2022 at 03:44, Dave wrote: >> >> Hi, >> >> 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! >> > >

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Avi Gross via Python-list
Dave, Despite your other programming knowledge, I suspect you think this is the forum where people come to be tutored. Try here: https://mail.python.org/mailman/listinfo/tutor Yes, there are plenty of pretty printers available and you can build your own function fairly easily. A module like

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Chris Angelico
On Fri, 10 Jun 2022 at 03:44, Dave wrote: > > Hi, > > 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

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread MRAB
On 2022-06-09 11:43, Dave wrote: Hi, 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! It's called "pretty-printing". Have a look at the 'pprint' module. --

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Larry Martell
On Thu, Jun 9, 2022 at 11:44 AM Dave wrote: > > Hi, > > 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! >>> import json >>> d = {'John': 'Cleese', 'Eric': "Idle", 'Micheal':