views:

64

answers:

2

Suppose I have a tuple in a list like this:

>>> t = [("asdf", )]

I know that the list always contains one 1-tuple. Currently I do this:

>>> dummy, = t
>>> value, = dummy
>>> value
'asdf'

Is there a shorter and more elegant way to do this?

+2  A: 

Try

(value,), = t
Lior
+5  A: 
>>> t = [("asdf", )]
>>> t[0][0]
'asdf'
Umang
*facepalm* - that one was obvious ...
Space_C0wb0y
Yet someone voted this question up...
Umang