[Python-ideas] Operator for inserting an element into a list

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jun 13 19:47:29 EDT 2018


Mikhail V wrote:
> But if you say that special-casing of [i:j] here would be hard to implement,
> then maybe insert() idea should be dropped.

Since I wrote that I realised that it's not true --
given an infix ^ operator like you propose, the in-place
version of it would actually give the desired result.

However, I still don't think that either insert or
append are frequent enough operations to warrant having
their own operators. It's true that append is a lot
more common than insert, but usually it's a mutating
append that you want, not creating a new list with
one more item on the end, which is what your ^
operator does.

-- 
Greg



More information about the Python-ideas mailing list