On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said...

A last one:

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2)))

This also works:


l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

pop=l.pop

dict([(pop(),pop()) for i in l])

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to