bugfix to yield #130

Merged
merged 1 commit into from Feb 1, 2017

Projects

None yet

2 participants

@wesyoung
Member
wesyoung commented Feb 1, 2017

No description provided.

@wesyoung wesyoung bugfix to yield
550afa7
@wesyoung wesyoung merged commit aacd0de into master Feb 1, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@wesyoung wesyoung deleted the fix/returns branch Feb 1, 2017
@JustinAzoff
Collaborator

Wait what?

That isn't right. A bare yield like that causes it to yield None to the calling function:

I don't think that is what you want at all.. in any case you shouldn't need them.

$ cat f.py;python3 f.py
def f():
    for x in range(10):
        if x % 2 == 0:
            continue
        yield x


for i in f():
    print(i)
1
3
5
7
9
$ cat f2.py;python3 f2.py
def f():
    for x in range(10):
        if x % 2 == 0:
            yield
            continue
        yield x


for i in f():
    print(i)
None
1
None
3
None
5
None
7
None
9
$
@wesyoung
Member
wesyoung commented Feb 2, 2017

it was resulting in a StopIteration exception for some reason..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment