A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033423.html below:

[Python-Dev] PEP308 alternative syntax: bool method

[Python-Dev] PEP308 alternative syntax: bool method [Python-Dev] PEP308 alternative syntax: bool methodMark Russell mrussell@verio.net
Fri, 14 Feb 2003 16:48:00 +0000
I know this subject has been beaten somewhat to death, but how about making
the if/then/else operator a method of the bool type, as in:

    var = (x > 10).choose(ifyes, ifno)

Choose() would need to be a special function of course to avoid evaluating the
non-selected choice.  I haven't seen this syntax proposed before, although I
have not waded through all the debate in comp.lang.python.

I would love to see some form of choice operator added, mainly because it
supports a functional style of programming -- I very much like to initialise
variables as they are introduced (and preferably not to assign to them later).

Mark Russell





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4