text-shadow: 0 0 20px #333;
padding: 2px 5px;
}
+ .indexlink {
+ position: absolute;
+ bottom: 1em;
+ left: 1em;
+ }
</style>
</head>
<body>
---
+layout: true
+
+.indexlink[[Index](index.html)]
+
+---
+
# Enciphering and deciphering
## Arithmetic on letters
---
+# Using the tools
+
+Before doing anything, create a new branch in Git
+
+* This will keep your changes isolated
+
+Experiment in IPython (ephemeral, for us)
+
+Once you've got something working, copy the code into a `.py` file (permanent and reusable)
+
+```python
+from imp import reload
+
+import test
+reload(test)
+from test import *
+```
+
+Re-evaluate the second cell to reload the file into the IPython notebook
+
+When you've made progress, make a Git commit
+
+* Commit early and often!
+
+When you've finished, change back to `master` branch and `merge` the development branch
+
+---
+
# The [string module](http://docs.python.org/3.3/library/string.html) is your friend
```python
```
---
+
# DRY and YAGNI
Is your code DRY?
---
-# Accents
-
-```python
->>> caesar_encipher_letter('é', 1)
-```
-What does it produce?
-
-What should it produce?
-
-## Unicode, combining codepoints, and normal forms
-
-Text encodings will bite you when you least expect it.
-
-* urlencoding is the other pain point.
-
----
-
-# Five minutes on StackOverflow later...
-
-```python
-def unaccent(text):
- """Remove all accents from letters.
- It does this by converting the unicode string to decomposed compatibility
- form, dropping all the combining accents, then re-encoding the bytes.
-
- >>> unaccent('hello')
- 'hello'
- >>> unaccent('HELLO')
- 'HELLO'
- >>> unaccent('héllo')
- 'hello'
- >>> unaccent('héllö')
- 'hello'
- >>> unaccent('HÉLLÖ')
- 'HELLO'
- """
- return unicodedata.normalize('NFKD', text).\
- encode('ascii', 'ignore').\
- decode('utf-8')
-```
-
----
-
-# Doing all the letters
+# Doing the whole message
## Test-first developement
---
-# Doing all the letters
+# Doing the whole message
## Abysmal
ciphertext += caesar_encipher_letter(plaintext[i], key)
```
+Try it in IPython
+
---
-# Doing all the letters
+# Doing the whole message
## Bad
---
-# Doing all the letters
+# Doing the whole message
## Good (but unPythonic)
---
-# Doing all the letters
+# Doing the whole message
## Best