3 ms·
I guess I'm missing the point. Why not use "Welcome %s to %s" % (who, place)
by BetaMechazawa 11y ago
I guess I'm missing the point. Why not use "Welcome %s to %s" % (who, place)
- hashmymustache 11y agoIt's easier to see the point with more variables being interpolated where it becomes cumbersome to keep track of the order and you end up recounting everything multiple times when something's out of place.
- PythonicAlpha 11y agoThis special syntax should be discouraged for any strings that shall be translated in the future. Different languages have different syntax, so the order can change, with this kind of syntax, you will be in big trouble very soon!
- nostrademons 11y agoFor anything translated, you'd use the (admittedly gross, fixed in Python3) "Welcome %(who)s to %(place)s" % { 'who': who, 'place': place }. The Python3 version is "Welcome {who} to {place}".format(place=place, who=who), or if you want to be un-idiomatic and unsafe, "Welcome {who} to {place}".format(locals())
- smcl 11y agoFrom the README.md: I really enjoyed Ruby String interpolation, and "".format(...) or "" % (...) seems very verbose to me. I'm lazy by nature ;)