[Python-ideas] Inline assignments using "given" clauses

Rhodri James rhodri at kynesim.co.uk
Mon May 14 07:26:51 EDT 2018

On 12/05/18 01:41, Juancarlo Añez wrote:
>>>    while (cmd := get_command()).token != CMD_QUIT:
>>>      cmd.do_something()
> while get_command() as cmd:
>      if cmd.token == CMD_QUIT:
>          break
>      cmd.do_something()

This would be exactly one of the patterns Python currently forces on me 
that I don't like.  This "while expr as name" form is not a win in my book.

Rhodri James *-* Kynesim Ltd

More information about the Python-ideas mailing list