Skip to content

Commit c8417ad

Browse files
Fix comparison between set and dictionary (#146)
The check `card_ords == {}` will always evaluate to `False`, even when it is empty. This is because `card_ords` is a set, and `{}` is a dictionary. >>> set() == {} False The intended check was probably something like "card ords is empty", which can be expressed as `if not card_ords`.
1 parent 9f78e4b commit c8417ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

genanki/note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _cloze_cards(self):
101101
field_value = self.fields[field_index] if field_index >= 0 else ""
102102
# update card_ords with each cloze reference N, e.g. "{{cN::...}}"
103103
card_ords.update(int(m)-1 for m in re.findall(r"{{c(\d+)::.+?}}", field_value, re.DOTALL) if int(m) > 0)
104-
if card_ords == {}:
104+
if not card_ords:
105105
card_ords = {0}
106106
return([Card(ord) for ord in card_ords])
107107

0 commit comments

Comments
 (0)