I am a very young programmer and I am trying to do something in Python but I\'m stuck. I have a list of users in Couchdb (using python couchdb library & Flask framework) who
You pass parameters to a jinja template as a dictionary d
when you call the template.renderfunction(d)
function (for example). Thus, you could do:
emails = []
for user in db:
doc = db[user]
emails.append(doc['email'])
some_jinja_template.render({'list_of_emails' : emails})
Then in the template, you could do something like:
{% for address in list_of_emails %}
- Send email to {{ address }}
{% endfor %}
To make a list of emails, for example, or handle them however you'd like.
PS - I'm sure the code could be more elegant/more optimized with a list comprehension or whatever, but I figured I should emphasize readability for a so-called "green" programmer.