June 19, 2018
12:56 a.m.
On Mon, Jun 18, 2018 at 5:52 PM Juancarlo Añez <apalala@gmail.com> wrote:
The idea is to introduce new syntax for the list.append() method.
mylist[] = item
For all practical purpose, it would be enough to define that the expression:
mylist += [item]
gets optimized to mylist.append(item).
Unfortunately, that would create yet another special case of operators breaking the rules. Most operators invoke magic methods. This would prevent ``+=`` from invoking ``__iadd__`` for lists, since the right-hand side would need to be compiled differently. It's similar to why ``and`` and ``or`` keywords can't have magic methods.