Code: Alles auswählen
to_Dict = lambda t: dict(map(None, map(lambda x: str(x), xrange(len(t))), t))
Beispiel:
Code: Alles auswählen
>>> to_Dict = lambda t: dict(map(None, map(lambda x: str(x), xrange(len(t))), t))
>>> to_Dict((1,2,3,4,5))
{'1': 2, '0': 1, '3': 4, '2': 3, '4': 5}
>>>
Noch ein Beispiel:
Code: Alles auswählen
>>> import time
>>> to_Dict = lambda t: dict(map(None, map(lambda x: str(x), xrange(len(t))), t))
>>> print "Time = %(3)02d:%(4)02d:%(5)02d" % to_Dict(time.localtime())
Time = 13:52:53
>>>
Gruß
Dookie