flat tuple
Duncan Booth
duncan.booth at invalid.invalid
Tue Sep 21 08:08:21 EDT 2004
Will McGugan wrote:
> What is the simplest way of turning a single value and a tuple in to a
> single 'flat' tuple?
>
> ie.
>
> t= ( 1, 2, 3 )
> n= 10
>
> n, t gives me ( 10, ( 1, 2, 3 ) )
>
> Fair enough, but I would like to get.. ( 10, 1, 2, 3 )
>
> I would like to use the result to create a string with the % operator -
> I was hoping there was some shorthand to produce ( n, t[0], t[1], t[2] ).
>
Tuples support concatenation so all you have to do is to wrap n in a tuple
then add them together:
format % ((n,) + t)
More information about the Python-list
mailing list