Mark Dickinson <dicki...@gmail.com> added the comment:

Which part of the behaviour do you think is a bug?

In version1, you want to think of the yield expression as though it were 
bracketed like this:

    result = yield (a+100 if b>100 else (yield a))

With the particular values of a and b that you have, that statement is 
equivalent to this:

    result = yield (yield 0)

This yields two values to the consumer: a `0` from the inner yield, followed by 
a None (or whatever was "sent" into the generator, if applicable) for the out 
yield.

In version 2, the corresponding line simplifies to just

    result = yield 0

So no, I don't think these two versions of the code should behave the same, and 
I don't think there's any bug here.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40354>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to