[Tutor] __getitem__ another problem
monikajg at netzero.net
monikajg at netzero.net
Wed Nov 23 01:26:13 EST 2016
Hi:
Can you please explain what is going on below? I do not understand how numbermap.__getitem__ brings back month's key.
Does numbermap.__getitem__ bring back numbermap key or value? If key then it is not consistent with my understanding of problem in my previous email. So month is sorted by numbermap values or keys?
month = dict(one='January',
two='February',
three='March',
four='April',
five='May')
numbermap = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5}
sorted(month, key=numbermap.__getitem__)
['one', 'two', 'three', 'four', 'five']
This is from:
http://pythoncentral.io/how-to-sort-python-dictionaries-by-key-or-value/
____________________________________________________________
Which Haircuts Look Exceptional on Older Women?
starsgossip.com
http://thirdpartyoffers.netzero.net/TGL3241/583536c537dff36c4036dst01duc
More information about the Tutor
mailing list