J
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() function:
File "<interactive input>", line 1, in <module>
ValueError: Invalid conversion specification
I'm running *** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***
(This is actually a PortablePython run on a Windows 7 machine)
Any idea why one form works and the other doesn't?
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() function:
Traceback (most recent call last):c = (1,3)
s = "{0[0]}"
print s.format(c) '1'
print format(c,s)
File "<interactive input>", line 1, in <module>
ValueError: Invalid conversion specification
I'm running *** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***
(This is actually a PortablePython run on a Windows 7 machine)
Any idea why one form works and the other doesn't?