What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Zachary Dziura
I have a dict that I would like to print out in a series of columns, rather than as a bunch of lines. Normally when you do print(dict), the output will look something like this: {'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1': ['1', '4', '7'], 'Header4': ['10', '11', '12']} I

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy
On 6/14/2011 11:29 AM, Zachary Dziura wrote: I have a dict that I would like to print out in a series of columns, rather than as a bunch of lines. Normally when you do print(dict), the output will look something like this: {'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1':

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Zach Dziura
d={'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'],     'Header1': ['1', '4', '7'], 'Header4': ['10', '11', '12']} arr = [] for key,value in d.items():      line = ['{:10s}'.format(key)]      for num in value:          line.append('{:10s}'.format(num))      arr.append(line) for

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Karim
On 06/14/2011 05:29 PM, Zachary Dziura wrote: I have a dict that I would like to print out in a series of columns, rather than as a bunch of lines. Normally when you do print(dict), the output will look something like this: {'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1':

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread MRAB
On 14/06/2011 18:48, Zach Dziura wrote: [snip] I just have one quick question. On the line where you have zip(*arr), what is the * for? Is it like the pointer operator, such as with C? Or is it exactly the pointer operator? [snip] The * in the argument list of a function call unpacks the

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Ben Finney
Zachary Dziura zcdzi...@gmail.com writes: What I want to know is how I can print out that information in a column, where the header is the first line of the column, with the data following underneath, like so: I'm glad you got some good replies. It probably reflects badly on me that my first

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 9:40 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Zachary Dziura zcdzi...@gmail.com writes: What I want to know is how I can print out that information in a column, where the header is the first line of the column, with the data following underneath, like so: I'm

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy
On 6/14/2011 2:37 PM, MRAB wrote: On 14/06/2011 18:48, Zach Dziura wrote: [snip] I just have one quick question. On the line where you have zip(*arr), what is the * for? Is it like the pointer operator, such as with C? Or is it exactly the pointer operator? [snip] The * in the argument list