On Mon, Jun 18, 2018 at 5:52 PM Juancarlo Añez <apal...@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.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to