[Python-ideas] Operator for inserting an element into a list
Mikhail V
mikhailwas at gmail.com
Tue Jun 12 11:17:04 EDT 2018
On Tue, Jun 12, 2018 at 5:54 PM, Mikhail V <mikhailwas at gmail.com> wrote:
> I think it would be logical to have the insert operator for lists.
> Similar to list extend operator += , it could use one of augmented
> assignment operators, e,g, /=.
>
> L = ["aa"]
>
> L[0] /= "bb"
>
> -> ["bb", "aa"]
>
> L[0] /= [1,2]
>
> -> [[1,2], "aa"]
>
> etc.
>
> Without index it would work like append():
Oops
Sorry for confusion, I inserted wrong examples here:
The examples should be :
L[0:0] /= "bb"
L[0:0] /= [1,2]
...
L[i:i] ^= e
Of course. Because L[i] /= is an operation on list element, thus
already working syntax.
More information about the Python-ideas
mailing list