Yes - maybe a proposal to have the MutableSequence protocol to define "<<" as "append" would be something with more traction than the original proposal here. No chanegs needed to to the language core, and
a = [1,2, 3] a <<= 4 resulting in a == [1, 2, 3, 4] is quite readable, syntactically valid, unambiguous (and can be implemented in two LoC for a new Sequence class). I know that at least Brython used the "<<=" enhanced assignement operator to manipulate HTML DOM, and it often results in quite compact code when compared with javascript-equivalente manipulations. On Mon, 18 Jun 2018 at 01:32, Robert Vanden Eynde <robertvandeney...@hotmail.com> wrote: > > 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): > self.append(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.hep...@gmail.com>: >> >> >> >> > On Jun 17, 2018, at 4:18 PM, Chris Angelico <ros...@gmail.com> wrote: >> > >> >> On Mon, Jun 18, 2018 at 3:01 AM, Mikhail V <mikhail...@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? >> >> — >> Clint >> >> _______________________________________________ >> Python-ideas mailing list >> Python-ideas@python.org >> https://mail.python.org/mailman/listinfo/python-ideas >> Code of Conduct: http://python.org/psf/codeofconduct/ > > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/