Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In the example from the end of the earlier post:

   y
   for x in xs
   if (y:=x.ComputeSomething()).IsFoo and y.IsBar


I suppose that works, although readability is not great, to put it mildly.


Much better would be

[(y:=x.ComputeSomething()) for x in xs if y.IsFoo and y.IsBar]


That doesn't work, because that first subexpression is evaluated last, after "if".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: