format() not behaving as expected

2012-06-29 Thread Josh English
I have a list of tuples, and usually print them using: print c, .join(map(str, list_of_tuples)) This is beginning to feel clunky (but gives me essentially what I want), and I thought there was a better, more concise, way to achieve this, so I explored the new string format and format()

Re: format() not behaving as expected

2012-06-29 Thread MRAB
On 29/06/2012 17:31, Josh English wrote: I have a list of tuples, and usually print them using: print c, .join(map(str, list_of_tuples)) This is beginning to feel clunky (but gives me essentially what I want), and I thought there was a better, more concise, way to achieve this, so I explored

Re: format() not behaving as expected

2012-06-29 Thread Steven D'Aprano
On Fri, 29 Jun 2012 09:31:53 -0700, Josh English wrote: I have a list of tuples, and usually print them using: print c, .join(map(str, list_of_tuples)) This is beginning to feel clunky (but gives me essentially what I want), and I thought there was a better, more concise, way to achieve

Re: format() not behaving as expected

2012-06-29 Thread Josh English
On Friday, June 29, 2012 10:02:45 AM UTC-7, MRAB wrote: The .format method accepts multiple arguments, so the placeholders in the format string need to specify which argument to format as well as how to format it (the format specification after the :). The format function, on the other

Re: format() not behaving as expected

2012-06-29 Thread Josh English
On Friday, June 29, 2012 10:08:20 AM UTC-7, Steven D#39;Aprano wrote: c = (1,3) s = {0[0]} print s.format(c) '1' That's not actually the output copied and pasted. You have quotes around the string, which you don't get if you pass it to the print command. Mea culpa. I typed it in

Re: format() not behaving as expected

2012-06-29 Thread MRAB
On 29/06/2012 18:19, Josh English wrote: On Friday, June 29, 2012 10:02:45 AM UTC-7, MRAB wrote: The .format method accepts multiple arguments, so the placeholders in the format string need to specify which argument to format as well as how to format it (the format specification after the :).