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 retur
On Thu, Dec 4, 2014, at 05:09, Albert van der Horst wrote:
> So in that case max doesn't return the maximum (True), but instead
> something else.
If you want to find the "largest" item in a list of of strings, sorted
case-insensitively, you might use str.lower or locale.strxfrm as the key
function
Steven D'Aprano writes:
> Jussi Piitulainen wrote:
>
> > Would you also want sorted called something else when used with a
> > key? Because it doesn't produce a sorted list of the keys either:
> >
> > >>> data = ("short", "long", "average")
> > >>> sorted(data, key=len)
> > ['long', 'short
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.
That is incorrect. It returns the maximum va
Jussi Piitulainen wrote:
> Would you also want sorted called something else when used with a key?
> Because it doesn't produce a sorted list of the keys either:
>
> >>> data = ("short", "long", "average")
> >>> sorted(data, key=len)
> ['long', 'short', 'average']
> >>> max(data, key=len)
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 sho
Albert van der Horst wrote:
> In article ,
> Peter Otten <__pete...@web.de> wrote:
>>Albert van der Horst wrote:
>>
>>> In the Rosetta code I come across this part of
>>> LU-decomposition.
>>>
>>> def pivotize(m):
>>> """Creates the pivoting matrix for m."""
>>> n = len(m)
>>> ID = [[
Albert van der Horst writes:
> Chris Angelico wrote:
> > If there's no clear maximum, it can't do any better than
> > that. It's still returning something for which there is no
> > greater.
>
> I agree that it is a useful function and that it is doing
> the right thing. What is wrong is the name.
Albert van der Horst writes:
> Useful as that function [Python's max with a key] may be, it
> shouldn't have been called max.
The meaning of the key should be added to help(max), if it still isn't
- "returns a maximal element or an element that maximizes the key".
In some communities they call i
In article ,
Chris Angelico wrote:
>On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst
> wrote:
>>>If there is more than one item with the maximum calculated the first is
>>>given, so for your attempt
>>>
>>>max(xrange(100,200), key=lambda i: i%17==0 )
>>
>>>
>>>the values False, False, True, F
On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst
wrote:
>>If there is more than one item with the maximum calculated the first is
>>given, so for your attempt
>>
>>max(xrange(100,200), key=lambda i: i%17==0 )
>
>>
>>the values False, False, True, False, ... are calculated and because
>>
>
In article ,
Peter Otten <__pete...@web.de> wrote:
>Albert van der Horst wrote:
>
>> In the Rosetta code I come across this part of
>> LU-decomposition.
>>
>> def pivotize(m):
>> """Creates the pivoting matrix for m."""
>> n = len(m)
>> ID = [[float(i == j) for i in xrange(n)] for j in
Albert van der Horst wrote:
> In the Rosetta code I come across this part of
> LU-decomposition.
>
> def pivotize(m):
> """Creates the pivoting matrix for m."""
> n = len(m)
> ID = [[float(i == j) for i in xrange(n)] for j in xrange(n)]
> for j in xrange(n):
> row = max(xr
13 matches
Mail list logo