Commits

Jure Žbontar committed 6fce381

Dict comprehensions are back

  • Participants
  • Parent commits e995b80

Comments (0)

Files changed (3)

         if not docids:
             return
     cur = ref.select_documents(headers, docids)
-    docs = dict((doc['docid'], str_document(doc)) for doc in cur)
+    docs = {doc['docid']: str_document(doc) for doc in cur}
 
     for i, line in enumerate(main_buf):
         id = get_docid(line)
     xml = Popen(cmd, stdout=PIPE).communicate()[0]
 
     fontspec = re.findall(r'<fontspec id="([^"]+)" size="([^"]+)"', xml)
-    font_size = dict((id, int(size)) for id, size in fontspec)
+    font_size = {id: int(size) for id, size in fontspec}
 
     chunks = []
     for id, text in re.findall(r'font="([^"]+)">(.*)</text>', xml):
         os.chmod(ref.DOCUMENT_DIR, 0755)
 
     def test_search_documents(self):
-        search = lambda q: dict((k, [row['docid'] for row in rows]) for k, rows in ref.search_documents(['docid'], q))
+        search = lambda q: {k: [row['docid'] for row in rows] for k, rows in ref.search_documents(['docid'], q)}
 
         self.assertDictEqual(search('feature'),
             {'author': [], 'fulltext': [2, 1], 'journal': [], 'notes': [], 'tags': [], 'title': [2]})