Re: [Python-ideas] Temporary variables in comprehensions

2018-02-17 Thread fhsxfhsx
A generator can be a good idea, however, I wonder if it's really readable to have a `f_samples`. And the structure is the same as in [y + g(y) for y in [f(x) for x in range(10)]] if you replace the list with a generator. And it's similar for other solutions you mentioned. Well, I know that it can

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-17 Thread fhsxfhsx
Thank you Paul, what you said is enlightening and I agree on most part of it. I'll propose two candidate syntaxs. 1. `with ... as ...` This syntax is more paralles as there would be `for` and `with` clause as well as `for` and `with` statement. However, the existing `with` statement is seman

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-17 Thread fhsxfhsx
You are right and actually I sometimes did the same thing in a temporary script such as in ipython. Because in my opinion, it's not really elegant code as one may be puzzled for the list `[f(x)]`. Well, although that's quite subjective. And also I test the code and find another `for` clause can

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-17 Thread fhsxfhsx
Hi Steve, Thank you for so detailed comments. My comments also below interleaved with yours. At 2018-02-16 08:57:40, "Steven D'Aprano" wrote: >Hi fhsxfhsx, and welcome. > >My comments below, interleaved with yours. > > >On Thu, Feb 15, 2018 at 01:56:44PM +0800, fhsxfhsx wrote: > >[quoted out