This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients Bryan Koch, greg.ewing, steven.daprano, terry.reedy
Date 2019-01-21.22:56:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20190121225611.GW13616@ando.pearwood.info>
In-reply-to <1548105675.24.0.46031706189.issue35756@roundup.psfhosted.org>
Content
> steven your generator example is exactly what I wanted to do; looks 
> like I'm upgrading to Python 3.8 for the new assignment syntax.
Sorry to have mislead you, but I don't think it will do what I thought. 
After giving it some more thought, I decided to test it (at least as 
much of it as possible). There's no local assignment here but you can 
see that the behaviour is not what I had assumed:

py> def inner():
...     yield from (1, 2)
...     return -1
...
py> def outer():
...     for x in (yield from inner()):
...             yield 100+x
...
py> for x in outer():
...     print(x)
...
1
2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in outer
TypeError: 'int' object is not iterable

In hindsight, this behaviour is logical. But I think it means that there 
is no way to do what you want using a for-loop.

> I was actually expecting the SyntaxError to be raised at runtime which 
> would be a pretty large behavior change

Not *entirely* unprecedented though, as you can get runtime SyntaxErrors 
from calling compile(), eval() or exec(). But I think some other class 
of exception would be better, since the problem isn't actually a syntax 
error.
History
Date User Action Args
2019-01-21 22:56:20steven.dapranosetrecipients: + steven.daprano, terry.reedy, Bryan Koch, greg.ewing
2019-01-21 22:56:18steven.dapranolinkissue35756 messages
2019-01-21 22:56:18steven.dapranocreate