class: center, middle # Caesar ciphers * Letter-by-letter enciphering --- # The [string module](http://docs.python.org/3.3/library/string.html) is your friend ```python import string string.ascii_letters string.ascii_lowercase string.ascii_uppercase string.digits string.punctuation ``` --- # Doctest * Why document? * Why test? --- # The magic doctest incantation ```python if __name__ == "__main__": import doctest doctest.testmod() ``` --- # Doing all the letters ## Abysmal ```python ciphertext = '' for i in range(len(plaintext)): ciphertext += caesar_encipher_letter(plaintext[i], key) ``` --- # Doing all the letters ## (Merely) Bad ```python ciphertext = '' for p in plaintext: ciphertext += caesar_encipher_letter(p, key) ``` --- # Doing all the letters ## Good (but unPythonic) ```python ciphertext = map(lambda p: caesar_encipher_letter(p, key), plaintext) ``` --- # Doing all the letters ## Best ```python ciphertext = [caesar_encipher_letter(p, key) for p in plaintext] ```