Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pythonic and concise way to construct this list?

How can I write the following code more concisely?

    scores = []
    for f in glob.glob(path):
        score = read_score(f, Normalize = True)
        scores.append(score)

I know this can be written in one or two lines without using append, but I'm a Python newbie.

like image 810
Frank Avatar asked May 15 '12 17:05

Frank


1 Answers

Oh, I got it while browsing a related question:

scores = [read_score(f, normalize=True) for f in glob.glob(path)]
like image 58
Frank Avatar answered Oct 17 '22 07:10

Frank