summaryrefslogtreecommitdiffstats
path: root/flashcards-project/src/flashcards/card.py
diff options
context:
space:
mode:
Diffstat (limited to 'flashcards-project/src/flashcards/card.py')
-rw-r--r--flashcards-project/src/flashcards/card.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/flashcards-project/src/flashcards/card.py b/flashcards-project/src/flashcards/card.py
new file mode 100644
index 0000000..3278343
--- /dev/null
+++ b/flashcards-project/src/flashcards/card.py
@@ -0,0 +1,12 @@
+"""
+Defines a struct representing a single card. The struct takes the form:
+
+(front, back)
+"""
+from collections import namedtuple
+from hashlib import md5
+
+Card = namedtuple('Card', ['front', 'back'])
+
+def getId(card: Card) -> str:
+ return md5((card.front + card.back).encode("utf-8")).hexdigest()