In the following code:
a = 'a'
tup = ('tu', 'p')
b = 'b'
print 'a: %s, t[0]: %s, t[1]: %s, b:%s'%(a, tup[0], tup[1], b)
How can I "expand" (can't figure out a better verb) tup
so that I don't have to explicitly list all its elements?
NOTE That I don't want to print tup
per-se, but its individual elements. In other words, the following code is not what I'm looking for
>>> print 'a: %s, tup: %s, b: %s' % (a, tup, b)
a: a, tup: ('tu', 'p'), b: b
The code above printed tup
, but I want to print it's elements independently, with some text between the elements.
The following doesn't work:
print 'a: %s, t[0]: %s, t[1]: %s, b:%s'%(a, tup, b)
In [114]: print '%s, %s, %s, %s'%(a, tup, b)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: not enough arguments for format string