[Python-ideas] Alternative spelling for list.append()
mike at selik.org
Mon Jun 18 20:56:34 EDT 2018
On Mon, Jun 18, 2018 at 5:52 PM Juancarlo Añez <apalala at 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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas