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

Alexander Heger python at 2sn.net
Tue Feb 3 01:40:38 CET 2015


>> Well, if something useful comes out of this discussion, maybe it would
>> be an idea to extend list to allow the former syntax naively assumed,
>>
>> list('foo', 'bar', 'baz')
>
> I see no point to this versus ['foo', 'bar', 'baz']
>
>> similar to what exists for dict():
>>
>> dict(a=1, b=2, c=3)

The point is that makes it easier for people to remember if they can
do it in a similar way.
(same would be for tuple()).  This way you could have pragmatic
verbose forms for all three, the only point of confusion being if
there is only one argument, which is iterable, the behaviour will be
different, i.e., the current default behaviour.

If a single non-iterable item gives a list as well, that could be
nice, but makes the outcome dependent on the type of the object.  A
concern could be that the result is less easy to predict when just
reading code.  But so are many things.

-Alexander


More information about the Python-ideas mailing list