WIP: Use assign expr in list comprehension by vstinner · Pull Request #8098 · python/cpython (original) (raw)
@@ -1341,9 +1341,9 @@ def _generate_toc(self):
if len(stops) < len(starts):
stops.append(line_pos - len(linesep))
starts.append(next_pos)
labels = [label.strip() for label
in self._file.readline()[1:].split(b',')
if label.strip()]
labels = [slabel for label
in self._file.readline()[1:].split(b',')
if (slabel := label.strip())]
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a counter-example to the "real programmers won't repeat stuff stuff today; they'll just move it to another line, which isn't that hard." (That said, I hope label.strip() is a relatively cheap operation, and that the second invocation will end up re-using the same location, so there won't be much memory churn.)
label_lists.append(labels)
elif line == b'\037' or line == b'\037' + linesep:
if len(stops) < len(starts):