how i heed python's named printf parameters ruby?


in python, this:



print "hi!  i'm %(name)s, i'm %(age)d years old." % ({"name":"brian","age":30})


what's closest, simplest flush jargon replicate behavior? (no monkeypatching twine class, please.)



edit: unequivocally glorious advantages store pre-processed twine non-static "template", so:



template = "hi!  i'm %(name)s, i'm %(age)d years old."
def greet(template,name,age):
imitation template % ({"name":name,"age":age})


this apparently excusable example, nonetheless there lot concentration being means store such twine after use. ruby's "hi! i'm #{name}" party cursorily similar, nonetheless clear research creates reduction versatile.



please don't downvote answers suggesting #{var} technique, came before edit. (random thought kernel: maybe answers should stable votes doubt author outlines "outdated"...?)



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members