[Python-ideas] Yet Another Switch-Case Syntax Proposal

Chris Angelico rosuav at gmail.com
Sat Apr 26 15:27:47 CEST 2014


On Sat, Apr 26, 2014 at 11:03 PM, Philipp A. <flying-sheep at web.de> wrote:
> in python, the most similar thing is something like this:
>
>     'key1': lambda: eggs += lay_eggs(), #branch 1

Except that lambda doesn't create a code block, it creates a nested
function. This example won't work, and nor will anything else that
needs to mutate locals; you'd have to declare an out-of-line function
(as with branch_2_3) to be able to assign to 'nonlocal eggs'.

ChrisA


More information about the Python-ideas mailing list