Proposal for new minor syntax
Jamie Willis
jw14896.2014 at my.bristol.ac.uk
Fri Mar 27 16:24:24 EDT 2015
I would like to propose a new piece of syntax for the python language; .=
In short, the operator is form of syntactic sugar, for instance consider
the following code:
hello = "hello world "
hello = hello.strip()
This could be written as:
hello = "hello world "
hello .= strip()
In this slightly contrived example, the programmer saved (a small amount
of) time when writing the code. With code with longer variable names, or
lots of similar statements all in a row, this helps to keep code more
concise.
The operator would be constricted to one method or field on the right-hand
side, which must belong to the object on the left hand side.
Another example could be when using Linked Lists, instead of writing
something like:
loop_node = loop_node.next
you could write:
loop_node .= next
Does this idea have any chance of acceptance if submitted as a PEP? What
are the potential concerns I could consider with the syntax?
Thanks,
Jamie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150327/efb90321/attachment.html>
More information about the Python-list
mailing list