Skip to content

Instantly share code, notes, and snippets.

@yyolk
Created August 29, 2013 20:48
Show Gist options
  • Save yyolk/6383218 to your computer and use it in GitHub Desktop.
Save yyolk/6383218 to your computer and use it in GitHub Desktop.
replace a for loop in a one-liner
def gen(asset):
# keywords = []
# for keyword in asset.all():
# keywords.append(str(keyword))
# return u'%s' % (", ".join(keywords))
# everything above replaced with below
return u'%s' % ", ".join([str(a) for a in asset.all()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment