converting tuple to list

Quinn Dunkan quinn at ngwee.ugcs.caltech.edu
Fri Jan 14 03:47:22 EST 2000


On Thu, 13 Jan 2000 15:14:59 +0100, Fredrik Lundh <fredrik at pythonware.com>
wrote:
>Adrian Eyre <a.eyre at optichrome.com> wrote:
>> Just out of interest: what is the canonical way of converting a list
>> of tuples to a dictionary? i.e. the opposite of dict.items()
>
>I doubt you can do much better than:
>
>mydict = {}
>for k, v in mylist:
>    mydict[k] = v

You can if you don't mind an extension: mal's mxNewBuiltins has a function
that does that.



More information about the Python-list mailing list