Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6988303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:03:43+00:00 2026-05-27T19:03:43+00:00

I was looking at Flask those days and in their user guide I found

  • 0

I was looking at Flask those days and in their user guide I found a Python snippet as below

@app.route('/')
def show_entries():
    cur = g.db.execute('select title, text from entries order by id desc')
    entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]
    return render_template('show_entries.html', entries=entries)

Here

entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]

creates a list of entries from the database. It is my first time to know to generate a list with a loop inside the bracket.

Can anyone help me point out where I can find the official intro. for such syntax ? is it only limited to list but not tuple nor anything else?

Many Thanks.
S.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:03:44+00:00Added an answer on May 27, 2026 at 7:03 pm

    The thing is called list comprehension

    I think this should be the official docs: http://docs.python.org/tutorial/datastructures.html#list-comprehensions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using flask on google app engine and am desperately looking for help
Thanks for looking. I am learning rails and am building a web app. I
I looking for something that I can either embed their uploader directly or send
Looking for a flash component for a website that has some characteristics of a
I'm looking for a Flash/Flex component which will create a popup editing balloon, similar
I'm looking for suggestions on Flash realtime servers. Currently, we use a combination of
I'm looking for advice on how to dynamically create content in flash based on
For a new project with Flash I was looking for something along the lines
I'm looking to use procedurally-generated sound and music in a Flash program I'm writing.
I am looking for ways that someone could maliciously pause a Flash movie -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.