What is the easiest way to convert Python dict e.g.:
a = {'a': 'value', 'b': 'another_value', ...}
into string using user format e.g.:
'%s - %s\n'
so it gives me:
a - value
b - another_value
This works, but maybe there is something shorter/better using map (without iterating over collection)
''.join(['%s %s\n' % o for o in a.items()])
'\n'.join('%s %s' % o for o in a.items())mapstill iterates over the collection, it just happens that sometimes it is faster and sometimes slower than an explicit loop.