[issue45989] Getting key of max value of dict really dose not sense

2021-12-05 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

The code makes perfect sense. If you want to find the maximum key in a dict, 
you write:

max(collective_signals)

If you want to find the maximum key according to some key function, you write:

max(collective_signals, key=function)


If you want to find the maximum key according to its associated value, the key 
function that will work is collective_signals.get. That makes perfect sense.

Not every one-line piece of code needs to be a builtin function.

In any case, Python 3.6 to 3.10 are all in feature-freeze. Even if we added 
some special function to do this, which I doubt we will do, it could only go 
into 3.11.

--
nosy: +steven.daprano
versions:  -Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45989] Getting key of max value of dict really dose not sense

2021-12-05 Thread Masoud Azizi


New submission from Masoud Azizi :

Maximum_signal_key=max(collective_signals,key=collective_signals.get)
This code is really hard to learn and remember.
Please change it to something that more sense.

--
messages: 407719
nosy: mablue
priority: normal
severity: normal
status: open
title: Getting key of max value of dict really dose not sense
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com