bryan.koch <bbkoc...@gmail.com> added the comment:
Thank you both for the clarifications. I agree these's no bug in `yield from` however is there a way to reference the return value when a generator with a return is invoked using `for val in gen` i.e. when the generator is invoked without delegation? I could write my own wrapper around using `next` to work around this but it might be an oversight of the new grammar (new being relative) that the return value is only available when invoked from the `yield from` syntax. Essentially I have code that looks like ` for value in generator: do thing with value yield value ` where I need to do something before yielding the value. It would be awesome if invoking a generator above would throw a SyntaxError iff it contained a return and it wasn't invoked through `yield from`. The below isn't valid Python and I'm not sure that it should be but it's what I need to do. ` return_value = for value in generator: do thing with value yield value if return_value: do something with return_value ` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35756> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com