For Python 3 users:
You can iterate through kwargs with .items()
subject = obj.subject
body = obj.body
for key, value in kwargs.items():
subject = subject.replace('[%s]' % key.toupper(), value)
body = body.replace('[%s]' % key.toupper(), value)
return (subject, body, obj.is_html)For Python 2 users:
You can iterate through kwargs with .iteritems():
subject = obj.subject
body = obj.body
for key, value in kwargs.iteritems():
subject = subject.replace('[%s]' % key.toupper(), value)
body = body.replace('[%s]' % key.toupper(), value)
return (subject, body, obj.is_html)from : https://stackoverflow.com/questions/8899129/how-do-i-loop-through-kwargs-in-python
No comments:
Post a Comment