dict turn to list at runtime unexpected!!!
dieter
dieter at handshake.de
Fri Dec 5 02:42:53 EST 2014
telnetgmike at gmail.com writes:
> Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks,
> addrnum_dict = {'a':1,'b':2}
> def orderaddrtimes():
> global addrnum_dict
> print type(addrnum_dict)
>
> addrnum_dict = sorted(addrnum_dict.iteritems(), key=lambda d:d[1], reverse = True)
"sorted" returns a list.
More information about the Python-list
mailing list