[Python-ideas] Alternative spelling for list.append()

Mikhail V mikhailwas at gmail.com
Tue Jun 19 09:57:20 EDT 2018


On Tue, Jun 19, 2018 at 3:52 AM, Juancarlo Añez <apalala at gmail.com> wrote:
>
>> The idea is to introduce new syntax for the list.append() method.
>>
>>
>> Syntax:
>>
>> Variant 1.
>> Use special case of index, namely omitted index:
>>
>>     mylist[] = item
>
>
> For all practical purpose, it would be enough to define that the expression:
>
> mylist += [item]
>
>
> gets optimized to mylist.append(item).

>From what I've read on SO about += ,there is not much penalty in comparison
to append() when using one item.

And besides, if your idea is to promote  += [item] spelling instead of
.append() method -
then might be you have a totally different idea than mine - so probably start
new discussion thread. I suspect though it has little sense because
such spelling is imo
nothing but obfuscation in terms of readability, and thankfully I
haven't seen a lot
of such usage. (and this all was many times discussed here too, so
please not again)



>
>
> --
> Juancarlo Añez


More information about the Python-ideas mailing list