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

Robert Vanden Eynde robertvandeneynde at hotmail.com
Sun Jun 17 19:58:52 EDT 2018

I understand the view from the poster, most basic list operations are using brackets, ie reading and writing with [], delete with del L[], why not append ?
And being used extensively, that brackets are annoying.
And yes, += [] is more "concise" than .append() so some people would think it's more clear because "it's smaller" (they'd be wrong as the OP mentioned).

But it would break the "There is only one Obvious way to do it" principle.
People would take time to figure out "okay, what should I write ? What's the most Pythonic ?"

If someone wants to use their own list class, it's doable with the current syntax :

class List(list):
    def __lshift__(self, x):
        return self

a = List([1,2,7,2])
a = a << 1 << 5
a <<= 0

2018-06-18 1:36 GMT+02:00 Clint Hepner <clint.hepner at gmail.com<mailto:clint.hepner at gmail.com>>:

> On Jun 17, 2018, at 4:18 PM, Chris Angelico <rosuav at gmail.com<mailto:rosuav at gmail.com>> wrote:
>> On Mon, Jun 18, 2018 at 3:01 AM, Mikhail V <mikhailwas at gmail.com<mailto:mikhailwas 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
> Creation of syntax cannot be done for just one type.

That’s false. @ was added solely for matrix multiplication.

> Regardless, I am still a strong -1 on introducing another way to spell
> list.append().

-1 as well. Has any one but the proposer shown any support for it yet?


Python-ideas mailing list
Python-ideas at python.org<mailto:Python-ideas at python.org>
Code of Conduct: http://python.org/psf/codeofconduct/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180617/3c72143a/attachment.html>

More information about the Python-ideas mailing list