[Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

Cammil Taank ctaank at gmail.com
Sat Apr 7 04:54:33 EDT 2018


> Care to repeat those arguments?

Indeed.

*Minimal use of characters*

The primary benefit for me would be the minimal use of characters, which
within list comprehensions I think is not an insignificant benefit:

    stuff = [[(f(x) as y), x/y] for x in range(5)]      # seems quite
syntactically busy

    stuff = [[y := f(x), x/y] for x in range(5)]        # better

    stuff = [[y! f(x), x/y] for x in range(5)]          # two fewer
characters (if you include the space after the identifier)

*Thoughts on odd usage of "!"*

In the English language, `!` signifies an exclamation, and I am
imagining a similar usage to that of introducing something by its name
in an energetic way. For example a boxer walking in to the ring:

"Muhammed_Ali! <in walks Muhammed Ali>", "x! get_x()"

I get that `!` is associated with "not", and factorial, but I couldn't
think of another character already used that would work in this usage.
I also think `name! expression` would be hard to interpret as a
comparison or factorial. I suppose the trade off here is efficiency
vs. idiosyncrasy. I very much appreciate this is all very tentative,
but I wanted to explain why this syntax does not sit terribly with me.

Cammil



On 7 April 2018 at 00:49, Steven D'Aprano <steve at pearwood.info> wrote:

> On Fri, Apr 06, 2018 at 03:27:45PM +0000, Cammil Taank wrote:
> > I'm not sure if my suggestion for 572 has been considered:
> >
> > ``name! expression``
> >
> > I'm curious what the pros and cons of this form would be (?).
>
> I can't see any pros for it. In what way is ! associated with assignment
> or binding? It might as well be a arbitrary symbol.
>
> (Yes, I know that ultimately *everything* is an arbitrary symbol, but
> some of them have very strong associations built on years or decades or
> centuries of usage.)
>
> As Peter says, ! is associated with negation, as in !=, and to those of
> us with a maths background, name! simply *screams* "FACTORIAL" at the
> top of its voice.
>
>
> > My arguments for were in a previous message but there do not seem to be
> any
> > responses to it.
>
> Care to repeat those arguments?
>
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180407/cebdaf3a/attachment-0001.html>


More information about the Python-ideas mailing list