dive into python chap 8