[Python-ideas] Method chaining notation
Stephen J. Turnbull
stephen at xemacs.org
Mon Feb 24 00:52:21 CET 2014
Ron Adam writes:
> The operator you want is one for an in place method call.
> seq = [] .= extend(get_data()) .= sort()
That looks like anything but Python to me. If I really thought of
that as a single operation, I'd do something like
class ScarfNSort(list):
def __init__(self):
self.extend(get_data())
self.sort()
seq = ScarfNSort()
If it doesn't deserve a class definition, then the repeated references
to 'seq' wouldn't bother me.
N.B. '.=' shouldn't be called "in-place": 'sort' and 'extend' are
already in-place. The word would be "chain," "cascade," or similar.
More information about the Python-ideas
mailing list