Migrate string formatting operations to str.format#1118
Conversation
| return "Take %s down and pass it around, " % ( | ||
| "one" if current_verse > 1 else "it" | ||
| return "Take {} down and pass it around, ".format( | ||
| "one" if current_verse > 1 else "it", |
There was a problem hiding this comment.
Was surprised that the Python interpreter doesn't complain about the trailing comma here; was there a particular reason for adding it?
There was a problem hiding this comment.
It's a stylistic thing that helps to avoid bugs and make diffs cleaner if someone adds an entry in future. It probably won't ever make a difference here, so I'm happy to remove them if you want - I mostly put them in to satisfy a flake8 extension that I have installed for other projects. They shouldn't cause issues though, since it's perfectly allowable in Python.
There was a problem hiding this comment.
Now you've got me curious: what's the extension? I've never seen an implementation of flake8/pep8/pyflakes that complains about those commas not being there.
Regarding this PR, I've no issue with leaving them. Was just curious.
There was a problem hiding this comment.
It's flake8-commas (PyPI). There are quite a few different extensions if you check pip search flake8.
I noticed that some of the exercises were still using the old style string formatting (eg.
"%s" % value) rather than using the newerstr.formatmethod - this PR moves everything to the newer style.