X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=utilities.py;h=ca984a30f96e4b09545eb09b277a5b0dc188be28;hb=3d8f7067b9c3a48ef140d7cff834d18ee91f58b3;hp=d1961a8a4e534e4cda82eee6249603dc5b4999de;hpb=21c390a77d42729afa23844ef2f1295106bed3de;p=cipher-tools.git

diff --git a/utilities.py b/utilities.py
index d1961a8..ca984a3 100644
--- a/utilities.py
+++ b/utilities.py
@@ -1,5 +1,6 @@
 import string
 import collections
+from itertools import zip_longest
 
 # join a a list of letters into a string
 cat = ''.join
@@ -11,17 +12,17 @@ wcat = ' '.join
 lcat = '\n'.join
 
 def pos(letter): 
-	"""Return the position of a letter in the alphabet (0-25)"""
+    """Return the position of a letter in the alphabet (0-25)"""
     if letter in string.ascii_lowercase:
         return ord(letter) - ord('a')
     elif letter in string.ascii_uppercase:
         return ord(letter) - ord('A')
     else:
-        return 0
+        raise ValueError('pos requires input of {} to be an ascii letter'.format(letter))
     
 def unpos(number): 
-	"""Return the letter in the given position in the alphabet (mod 26)"""
-	return chr(number % 26 + ord('a'))
+    """Return the letter in the given position in the alphabet (mod 26)"""
+    return chr(number % 26 + ord('a'))
 
 def every_nth(text, n, fillvalue=''):
     """Returns n strings, each of which consists of every nth character, 
@@ -160,10 +161,6 @@ def index_of_coincidence(text):
     )
 
 
-transpositions = collections.defaultdict(list)
-for word in keywords:
-    transpositions[transpositions_of(word)] += [word]
-
 def frequencies(text):
     """Count the number of occurrences of each character in text
 
@@ -192,3 +189,6 @@ def frequencies(text):
     0
     """
     return collections.Counter(c for c in text)
+
+if __name__ == "__main__":
+    import doctest
\ No newline at end of file