[Python-ideas] [Python-Dev] Language proposal: variable assignment in functional context

Sven R. Kunze srkunze at mail.de
Mon Jun 26 12:43:54 EDT 2017


Cool idea, Michał. I hope there's at least somebody willing to try it 
out in practice.


On 23.06.2017 02:21, Michał Żukowski wrote:
> I've implemented a PoC of `where` expression some time ago.
>
> https://github.com/thektulu/cpython/commit/9e669d63d292a639eb6ba2ecea3ed2c0c23f2636
>
> just compile and have fun.
>
>
>
> 2017-06-17 2:27 GMT+02:00 Steven D'Aprano <steve at pearwood.info 
> <mailto:steve at pearwood.info>>:
>
>     Welcome Robert. My response below.
>
>     Follow-ups to Python-Ideas, thanks. You'll need to subscribe to
>     see any
>     further discussion.
>
>
>     On Fri, Jun 16, 2017 at 11:32:19AM +0000, Robert Vanden Eynde wrote:
>
>     > In a nutshell, I would like to be able to write:
>     > y = (b+2 for b = a + 1)
>
>     I think this is somewhat similar to a suggestion of Nick
>     Coghlan's. One
>     possible syntax as a statement might be:
>
>     y = b + 2 given:
>         b = a + 1
>
>
>     https://www.python.org/dev/peps/pep-3150/
>     <https://www.python.org/dev/peps/pep-3150/>
>
>     In mathematics, I might write:
>
>     y = b + 2 where b = a + 1
>
>     although of course I wouldn't do so for anything so simple. Here's a
>     better example, the quadratic formula:
>
>           -b ± √Δ
>     x =  ─────────
>              2a
>
>     where Δ = b² - 4ac
>
>     although even there I'd usually write Δ in place.
>
>
>     > Python already have the "functional if", lambdas, list
>     comprehension,
>     > but not simple assignment functional style.
>
>     I think you mean "if *expression*" rather than "functional if".
>     The term
>     "functional" in programming usually refers to a particular paradigm:
>
>     https://en.wikipedia.org/wiki/Functional_programming
>     <https://en.wikipedia.org/wiki/Functional_programming>
>
>
>     --
>     Steve
>     _______________________________________________
>     Python-ideas mailing list
>     Python-ideas at python.org <mailto:Python-ideas at python.org>
>     https://mail.python.org/mailman/listinfo/python-ideas
>     <https://mail.python.org/mailman/listinfo/python-ideas>
>     Code of Conduct: http://python.org/psf/codeofconduct/
>     <http://python.org/psf/codeofconduct/>
>
>
>
>
> _______________________________________________
> 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/20170626/d45456a1/attachment.html>


More information about the Python-ideas mailing list