Fix _prettyprint after 'for i in range' changed to 'for i, val in enumerate'. #1384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just FYI @henryiii: changing
into a for loop with
and all
out[i]
on the right-hand side of assignments converted intoval
broke this functionality. The original for loop relied on a side-effect in whichout[i]
was changed twice. Using an assigned-once name,val
, prevented the first change from being seen in the final result.I repeatedly run into cases in which side-effect turn out to be a bad idea (there's really something to this pure functional paradigm), and this could be counted as one of them. But side-effect based programming is a part of ordinary Python use and I wanted to bring to your attention that there are corner-cases like this in which
for i in range(len(XYZ))
→for i, val in enumerate(XYZ)
can be dangerous. Not to avoid these refactorings, but to keep an eye out for them!(Also, I haven't yet checked the history to be sure that that's how this bug crept in, I'm just guessing that because it looks like it.)