On 16Jun2018 02:42, Mikhail V <mikhail...@gmail.com> wrote:
Now I have slightly different idea. How is about special-casing of this
as a shortcut for append:
L[] = item
Namely just use the fact that empty slice is SyntaxError now.
Now we're just making typing errors into working code.
Also, that isn't an empty slice. That's a _missing_ slice. An empty slice has
zero length.
While genuinely new syntax needs to land in such a gap (because otherwise it
will break working code), new syntax needs a much highly value than new
meanings for existing operators.
Some things _should_ be syntax errors. Particularly things which may be typing
errors. Suppose I'd meant to type:
L[0] = item
Silent breakage, requiring runtime debugging.
I understand this is totally different approach than operator
overloading and maybe
hard to implement, but I feel like it looks really appealing.
And it is quite intuitive imo. For me the syntax reads like:
"add new empty element and this element will be "item".
The term "new empty element" is a nonsense term to me.
If you mean "replace an empty slice at the end of the list with a new element",
that can already be written:
L[len(L):len(L)]=[9]
Cumbersome, I accept. But I've got a .append method.
Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/