I have a tuple, for example ('key1', 'value1') , which I want to add to the dictionary, so it looks like {'key1': 'value1'} but does not do something like dictionary[t[0]] = t[1] .
The context is this: I have a repeat rule that looks like this:
FREQ=WEEKLY;UNTIL=20120620T233000Z;INTERVAL=2;BYDAY=WE,TH
And I want to have such a recorder:
recurrence = { 'freq' : 'weekly', 'until' : '20120620T233000Z', 'interval' : '2', 'byday' : 'we,th' }
And I am doing something like this:
for rule in recurrence.split(';'): r = rule.split('=') rules[r[0]] = r[1]
And I donβt like it at all. Is there a more pythonic way to do this?
licorna
source share