osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Assignment expression and coding style: the while True case


05.07.18 03:03, Victor Stinner ????:
> +                labels = [slabel for label
> +                          in self._file.readline()[1:].split(b',')
> +                          if (slabel := label.strip())]

                 labels = [slabel for label
                           in self._file.readline()[1:].split(b',')
                           for slabel in [label.strip()]
                           if slabel]

> +        lines = [match.group(1, 2)
> +                 for raw_line in raw_lines
> +                 if (match := line_pat.search(raw_line.strip()))]

         lines = [match.group(1, 2)
                  for raw_line in raw_lines
                  for match in [line_pat.search(raw_line.strip())]
                  if match]

But in all these cases I prefer the original loop.