allowed_genres is an array of strings. The for loop and else block are
there to turn the array into 1 string with commas as part of the string.

For example, 'House, Techno, Death Metal'. :-)

Wouldn't ','.join(allowed_genres) end up like;
',House Techno Death Metal'?

I am very new to Python so I might not understand what that join
statement does.

As it turns out, I want the block after the else to always execute since
it lets the last genre term in without being followed by a comma.

If your ','.join means delimit the array of strings with a comma then,
yes, your solution is far cleaner and more readable.

On 13-09-26 03:14 PM, Adrian Sampson wrote:
>> for genre in list(genres): if _is_allowed(genre): -
>> return genre.title()  # Title case. -    return None +
>> allowed_genres.append(genre.title()) + +#    pdb.set_trace() + +
>> for genre in allowed_genres[:-1]: +        genre = genre + ', ' +
>> allowed_genres_copy.append(genre) +    else:
> 
> Sorry, momentary brainfart—I meant to say that the block is *always*
> executed because there's no `break`. (In Python, the `else` block in
> a `for` is only executed if the loop doesn't break.)
> 
> Overall, is it correct to say that this loop (and the lines below)
> could be replaced with `return ', '.join(allowed_genres)`?
> 
> --- Reply to this email directly or view it on GitHub: 
> https://github.com/sampsyo/beets/pull/397/files#r6611183
>