Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81912
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: How is max supposed to work, especially key. |
| Date | 2014-12-04 10:47 -0500 |
| References | <547760b3$0$6876$e4fe514c@dreader36.news.xs4all.nl> <mailman.16378.1417111312.18130.python-list@python.org> <548032dd$0$15926$e4fe514c@dreader35.news.xs4all.nl> <mailman.16552.1417688329.18130.python-list@python.org> <548038f8$0$15841$e4fe514c@dreader35.news.xs4all.nl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16562.1417708068.18130.python-list@python.org> (permalink) |
On 12/4/2014 5:35 AM, Albert van der Horst wrote: > I agree that it is a useful function and that it is doing > the right thing. What is wrong is the name. > I refer to the fact that it is not returning the maximum. > It returns the iterator value that leads to the maximum. > A function that doesn't return a maximum shouldn't be called > maximum. The key function serves the same purpose as with sort. It define a custom ordering of items, not the values returned. 'x < y' is defined as key(x) < key(y), where the comparison of keys uses the standard (and for numbers, natural) built-in ordering. So max returns the max value according to the order you define with the key function. The default key is the identity function, so the default order is the builtin order. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How is max supposed to work, especially key. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-11-27 17:34 +0000
Re: How is max supposed to work, especially key. Peter Otten <__peter__@web.de> - 2014-11-27 19:01 +0100
Re: How is max supposed to work, especially key. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-12-04 10:09 +0000
Re: How is max supposed to work, especially key. Chris Angelico <rosuav@gmail.com> - 2014-12-04 21:18 +1100
Re: How is max supposed to work, especially key. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-12-04 10:35 +0000
Re: How is max supposed to work, especially key. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-04 12:51 +0200
Re: How is max supposed to work, especially key. Peter Otten <__peter__@web.de> - 2014-12-04 12:31 +0100
Re: How is max supposed to work, especially key. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-04 23:03 +1100
Re: How is max supposed to work, especially key. Terry Reedy <tjreedy@udel.edu> - 2014-12-04 10:47 -0500
Re: How is max supposed to work, especially key. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-04 12:45 +0200
Re: How is max supposed to work, especially key. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-04 22:55 +1100
Re: How is max supposed to work, especially key. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-04 14:58 +0200
Re: How is max supposed to work, especially key. Peter Otten <__peter__@web.de> - 2014-12-04 12:24 +0100
Re: How is max supposed to work, especially key. random832@fastmail.us - 2014-12-04 09:09 -0500
csiph-web