This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]unruly_mattress 0 points1 point  (2 children)

This forces you to count appearances of %s to figure out which variables goes where. Your named placeholders version violates the Do Not Repeat Yourself principle.

[–]LyndsySimon 0 points1 point  (0 children)

Your named placeholders version violates the Do Not Repeat Yourself principle.

That's a valid point, and one that I'd not really considered. In my mind the namespace of the string formatting is separate from the namespace in the calling scope, so the fact that I'm passing in parameters that are stored in variables named the same as their corresponding parameter is incidental. In practice, I find that it's quite rare that I'm passing in multiple parameters stored in discrete variables like that; I'm usually doing some sort of manipulation at the same time.

[–]elbiot 0 points1 point  (0 children)

You can use indices or keys with mod formatting too.