[issue41795] Allow assignment in yield statement

2020-09-16 Thread Ronald Oussoren
Change by Ronald Oussoren : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Pytho

[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann
Richard Neumann added the comment: Awesome, I didn't know that. I tried it without the parens and it gave me a SyntaxError. This can be closed then as it's obviously already implemented. Let's get to refactoring. -- ___ Python tracker

[issue41795] Allow assignment in yield statement

2020-09-16 Thread Ronald Oussoren
Ronald Oussoren added the comment: You can already do this with the walrus operator: # --- def test(): for i in range(10): yield (square := i * i) yield square + 1 # --- This adds some parenthesis to your second alternative. -- nosy: +ronaldoussoren ___

[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann
New submission from Richard Neumann : I often write factory (deserialization) methods for ORM models for web application backends that produce a number of records (ORM model instances) of itself and related database tables: @classmethod def from_json(cls, json): """Yields reco