[Python-ideas] How do you think about these language extensions?
Chris Barker
chris.barker at noaa.gov
Fri Aug 18 14:47:40 EDT 2017
>> # arrow transform (to avoid endless parentheses and try to be more
readable.
> >>
> >> >> range(5) -> map(.x->x+2, _) -> list(_)
> >> >> [2,3,4,5,6]
> >
> > I like the idea of chained function calls
parentheses aren't that bad, and as far as I can tell, this is just another
way to call a function on the results of a function.
The above is now spelled:
list(map(lambda x: x+2, range(5)))
which seems fine with me -- the only improvement I see is a more compact
way to spell lambda. (though really, a list comp is considered more
"pythonic" these days, yes?
[x+2 for x in range(5)]
nicely, we have list comps and generator expressions, so we can avoid the
list0 call.
I know this was a simple example for demonstration's sake, but doesn't look
like an improvement to me.
Of course, in this case, it's chaining iterations, not "ordinary"
functions, so maybe would make more sense in other contexts.
Also, we need to remember that functions can take *args, **kwargs, etc,
and can return a tuple of just about anything -- not sure how well that
maps to the "pipe" model.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170818/e5e46cd3/attachment-0001.html>
More information about the Python-ideas
mailing list