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/2018-April/152904.html below:

[Python-Dev] PEP 572: Assignment Expressions

[Python-Dev] PEP 572: Assignment Expressions [Python-Dev] PEP 572: Assignment ExpressionsSven R. Kunze srkunze at mail.de
Mon Apr 23 17:34:22 EDT 2018
On 23.04.2018 23:19, Barry Warsaw wrote:
> I also think it effectively solves the switch-statement problem:
>
> if (get_response() as answer) == 'yes':
>      do_it()
> elif answer == 'no':
>      skip_it()
> elif answer == 'maybe'
>      okay_then()
>
> That’s Pythonic enough for jazz!

Is it just me or since when has the following Python code fallen out of 
favor?

answer = get_response()
if answer == 'yes':
     do_it()
elif answer == 'no':
     skip_it()
elif answer == 'maybe'
     okay_then()

I really don't see anything I would want to optimize here. Not even a 
single bit. But as said that might just be me.

What I like about this code is:
1) symmetry: all ifs are equally structured
2) classic IPO model: first get input, then process (, then output)

Sven
More information about the Python-Dev mailing list

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