[Python-ideas] More useful slices

João Santos jmcs at jsantos.eu
Mon Feb 2 13:48:33 CET 2015


 L = ['foo', 'bar', 'baz'] is syntactic sugar, you can write L =
list('foo', 'bar', 'baz')

On 2 February 2015 at 13:43, Rob Cliffe <rob.cliffe at btinternet.com> wrote:

>
> On 02/02/2015 12:38, Todd wrote:
>
>  On Mon, Feb 2, 2015 at 1:10 PM, Rob Cliffe <rob.cliffe at btinternet.com>
> wrote:
>
>>
>> On 02/02/2015 11:19, Todd wrote:
>>
>>
>> On Mon, Feb 2, 2015 at 11:53 AM, Chris Angelico <rosuav at gmail.com> wrote:
>>
>>> On Mon, Feb 2, 2015 at 9:26 PM, Todd <toddrjen at gmail.com> wrote:
>>> > First, it wouldn't be a replacement.  The existing range syntax would
>>> still
>>> > exist.
>>> >
>>> > But the reason it is beneficial is the same reason we have [a, b, c]
>>> for
>>> > list, {a:1, b:2, c:3} for dicts, {a, b, c} for sets, and (a, b, c) for
>>> > tuples.
>>
>>    Well, we have to have *some* syntax for literal lists, dicts etc.
>> But we already have range, so there is no compelling need to add new
>> syntax.
>>
>
>  Why do we need literals at all?  They are just syntactic sugar.  Python
> went a long time without a set literal.
>
> Well, if you'd rather write
>     L = list()
>     L.add('foo')
>     L.add('bar')
>     L.add('baz')
> than
>     L = ['foo', 'bar', 'baz']
> then good luck to you.
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150202/a16242cd/attachment.html>


More information about the Python-ideas mailing list