Sorry, I forgot that you dropped the suggestion to make it an insert
operator and are only asking for an append operator.

I see no benefit to this, because += already is an elegant way to extend a
list, which is more flexible than append. Yes, if the right-hand is an
iterable and should be appended as a single element, you'll need to enclose
it in a single-element container. This is true for strings, lists, sets,
whatever. It's natural and is not a "trick".

If you would like to prove the need for this operator, one piece of
evidence you can provide is a count of the number of times someone writes
"list.append" for an iterable vs "+=" and encloses a str or other type in a
throw-away list to effectively append.

If the latter habit is common, that's evidence that the language may need
to be improved. Why don't you search GitHub projects to collect some
statistics?


On Thu, Jun 14, 2018, 7:40 PM Michael Selik <m...@selik.org> wrote:

>
>
> On Thu, Jun 14, 2018, 7:24 PM Mikhail V <mikhail...@gmail.com> wrote:
>
>> what haven't we repeated in this thread yet? Motivation was explained.
>>
>
> You have repeated your explanations a few times. It isn't convincing.
>
> It seems to me that your main complaint is that strings are iterable,
> though you haven't expressed it as such. During slice assignment, you're
> surprised that the string is a sequence of characters. I understand, but I
> don't find that confusion a compelling reason to add a new operator.
>
> About confusion probably haven't discussed : so Xor ^ works on sets,
>> IIRC for finding
>> union without common elements.
>>
>
> I wrote about this in an earlier email, which you didn't reply to. You're
> correct that xor doesn't make sense with lists, especially not between a
> list and a single element.
>
> Again, though other operators have been given different meanings in
> special contexts, those decisions should be seen as abnormal, not an excuse
> to keep creating more special cases.
>
>>
_______________________________________________
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