
M Bfmv writes:
``` if [i for i in range(10) if i == 11]: print(this)
Evaluate: [] ```
This usage of 'this' in that code is called "anaphora". It's very useful in natural language and most (all? :-) natural languages have it, but in a programming language it requires a convention (that must be learned and remembered by anyone who reads your code, including last year's lint programs!) and either requires reserving the conventional identifier (in your case, 'this') or creating ambiguity when some programmer uses it for something else. Some programming languages have it. Python has preferred to avoid it. The assignment operator (aka "walrus operator") that others have pointed out is a good compromise IMO: if this := [i for i in range(10) if i == 11]: print(this) Of course the walrus operator is very new and has the same burden on human readers and linters, but it's far more flexible and useful than the implicit use of anaphora. I think the addition of the walrus operator means there will be no anaphora in Python ever. Steve