From e238d8822505179cba3c34d1fd04013e4394236d Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Wed, 9 May 2012 21:49:55 +0300 Subject: [PATCH] Commented on a nested list comprehension, following f96d73d2 --- jrnl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jrnl.py b/jrnl.py index 2cae6b13..fccb0cc1 100755 --- a/jrnl.py +++ b/jrnl.py @@ -457,7 +457,10 @@ if __name__ == "__main__": print(journal) elif args.tags: # get all tags + # Astute reader: should the following line leave you as puzzled as me the first time + # I came across this construction, worry not and embrace the ensuing moment of enlightment. tags = [tag for entry in journal.entries for tag in set(entry.tags)] + # To be read: [for entry in journal.entries: for tag in set(entry.tags): tag] tag_counts = {(tags.count(tag), tag) for tag in tags} for n, tag in sorted(tag_counts, reverse=True): print "%-20s : %d" % (tag, n)