0

About a week ago I saw a script using kwargs in the string template. Unfortunately I can't re-find that script so I thought I'd ask to see if anyone knows of a way that I can pass kwargs into the string builder rather then just args.

Here is the desired result:

"""%name went to the store.""" %( name = John )

Naturally, this won't work and for the life of me I cannot remember the proper syntax.

1

1 Answer 1

3
"""%(name)s went to the store.""" % {"name": "John"}

or

"""%(name)s went to the store.""" % dict(name="John")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.