[Python-ideas] change list() - branch from "More useful slices"

Rob Cliffe rob.cliffe at btinternet.com
Mon Feb 2 23:25:49 CET 2015


On 02/02/2015 22:21, Georg Brandl wrote:
> On 02/02/2015 11:03 PM, Eugene Toder wrote:
>> On Mon, Feb 2, 2015 at 4:19 PM, Ryan Gonzalez
>> <rymg19 at gmail.com
>> <mailto:rymg19 at gmail.com>> wrote:
>>
>>      On Mon, Feb 2, 2015 at 1:47 PM, Thomas Kluyver
>>      <thomas at kluyver.me.uk
>>      <mailto:thomas at kluyver.me.uk>> wrote:
>>
>>          max() and min() do behave like this - they accept either a single
>>          iterable, or *args - so it's not unprecedented. But I don't see any
>>          benefit to adding it to the list() constructor.
>>
>>
>>      Because the maximum/minimum of a single value makes absolutely no sense, but
>>      a single-element list does.
>>
>> Arguably, min and max of a single value is that same value. This is what min()
>> and max() return when you pass them a 1-element sequence.
> Yes, but that's beside the point.  The point is that for max and min
> it is never needed to write "min(a)" or "max(a)" where a is not a
> sequence -- since it's the same as just "a".
>
> Georg
>
>
In fact,
     min(3,4) == min((3,4)) ==  min((3,)) == 3
but
     min(3) raises an error
whereas attempting to create a single-item list should not be an error.
Rob Cliffe



More information about the Python-ideas mailing list