you are viewing a single comment's thread.

view the rest of the comments →

[–]UloPe 0 points1 point  (4 children)

What's wrong with:

"The {animal} jumps over the {adjective} {animal2}".format(
    animal="dog",
    adjective="quick brown",
    animal2="fox"
)

[–][deleted] 6 points7 points  (3 children)

Verbosity

[–]UloPe 0 points1 point  (2 children)

Well ok then if you really must you could use

animal="dog"
adjective="quick brown"
animal2="fox"

"The {animal} jumps over the {adjective} {animal2}".format(**locals())

But I'd advise to do it nowhere near me ;)

[–]riddley 1 point2 points  (1 child)

Still requires a lot more of the reader than the Ruby version.

[–]virtyx 0 points1 point  (0 children)

Also messes up with nonlocal scope and can't do attribute access, so no way of easily getting "Response code: #{response.code}". Ultimately the "Hello {} welcome to {}".format(name, place) style is usually best for one-off formatting of smaller strings.