Builtin `min()` does not support argument `key`
I have the following code:
distances = {'a': 4, 'b': 1}
queue = ['a', 'b']
u = min(queue, key=distances.get)
queue.remove(u)
print(queue)
When run with Python 3.11.1, I get the expected result printed:
> python3 min_example.py
['a']
If I try to run it with Codon 0.16.2, I get the following:
> codon run min_example.py
min_example.py:3:20-33: error: 'key' is an invalid keyword argument for min()
Is this expected? I assumed the key parameter would be supported for min().
Thanks for the report -- yes we definitely should support that. We'll plan to have it in the next release!
Awesome, thanks very much!
By the way, this is also the case for max().
For example, for finding the most common letter in letters, this is a short way of writing it:
most_common = max(set(letters), key=letters.count)
Unfortunately this still throws an error in Codon 0.16.3:
error: 'key' is an invalid keyword argument for max()
Hi @akleemans, I've created a PR for this here: https://github.com/exaloop/codon/pull/505 -- it'll be included in the next version that we plan to release in the next couple weeks!
Awesome, appreciate it!
I see PR #505 was merged and this issue can be closed now.
As @avitkauskas pointed out, this has been merged, closing.