Worthwhile to reverse a dictionary
Kent Johnson
kent at kentsjohnson.com
Thu Dec 15 12:53:11 EST 2005
rudysanford at hotmail.com wrote:
> What is the difference between
>
> " d1 = {'A' : '1', 'B' : '2', 'C' : '3'} "
>
> and
>
> " d1 = dict(A = 1, B = 2, C = 3) " ?
>
> All of the dictionary examples I saw (python.org, aspn.activestate.com,
> Learning Python by Lutz, among others) use d={'x' : 'y'}.
>
The second form is only available in Python 2.3 and newer, so any example that is older
than that will use the first form.
Kent
More information about the Python-list
mailing list