12.06.18 17:54, Mikhail V пише:
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():

     L /= "bb"

     #->  ["aa", "bb"]


As for possible spellings I like this one as well:

     L[i] ^= e

The proposed solution is meant to have insert() method semantics,
plus it would cover append() method nicely.

Insert and append are very frequent operations, so I wonder
if there was already related suggestion?   Is there some technical
problem with implementing this?

Nice idea for your language.

_______________________________________________
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