[Python-ideas] If branch merging

random832 at fastmail.us random832 at fastmail.us
Sun Jun 7 05:40:55 CEST 2015


On Sat, Jun 6, 2015, at 23:03, Cory Beutler wrote:
> # New Version using 'as' keyword
> if a == b as aisb:
>     print ('a == b')

> I realize that using the 'as' keyword may not be the best. Using 'as'
> seems
> to suggest that it will only be used in the following block. An
> alternative
> to using the 'as' keyword could be assigning the 'if' to a variable like
> so:
> aisb = if a == b:
> This looks a bit gross to me, though. If think of a better one, I would
> love to see it.

Well you could always go with if aisb = a == b.

I'm not sure there is a convincing reason to allow your case (assign
within an if statement) that doesn't also work just as well as a general
argument for assignment expressions.


More information about the Python-ideas mailing list