(why) inconsistent yield/return syntax?

Skip Montanaro skip at pobox.com
Mon Feb 10 22:01:04 CET 2003


    Gerrit>  45 >>> def f(): return
    Gerrit>  45 ...
    Gerrit>  46 >>> def f(): yield
    Gerrit>   File "<stdin>", line 1
    Gerrit>     def f(): yield

    Gerrit> Why is there a difference?

Are you asking why it doesn't implicitly return None or specifically why
your example failed?  If the former, you'll have to ask the authors of PEP
255.  If the latter, it's because there is no implicit yield of None.

Skip





More information about the Python-list mailing list