On Sat, 28 Mar 2015 07:48 am, Ian Kelly wrote: > On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis > <jw14896.2...@my.bristol.ac.uk> wrote: >> 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. > > Do you mean that this would not be legal? > > hello .= strip().upper().encode('utf-8') > > Is there a reason you want to disallow that? > >> Another example could be when using Linked Lists, instead of writing >> something like: >> >> loop_node = loop_node.next >> >> you could write: >> >> loop_node .= next > > I realize this is just an example, but does anybody actually use > linked lists in Python outside of class assignments? It seems hard to > justify performance-wise since list is written in C, and if you need > to beat it, then you probably shouldn't be doing so in Python.
https://www.safaribooksonline.com/library/view/python-cookbook/0596001673/ch14s05.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list