Skip to content

Reading Update: Short Reviews

I’ve been delinquent in posting about what I’ve been reading. Rather than continue with the charade that I’ll eventually write full reviews for each book, I present a set of short reviews that should get me more or less caught up.

Tweak: Growing Up on Methamphetamines by Nic Sheff

As part of the memoir writing class I took last fall, we read David Sheff’s book, Beautiful Boy, which tells the story of watching his promising young son struggle with drug and alcohol addiction. His son’s book, Tweak, tells his own wrenching story. When I read American Psycho a few years ago there were times I was so disturbed I sort of held the book at arm’s length and read through squinted eyes. I had the same experience with Tweak, amplified by knowing what I read was true. Tweak is not a perfect memoir — Sheff acknowledges some mistakes and missteps in the afterword — but it manages to convey the roller coaster of insanity Sheff went through as an addict, a recovering addict, and a relapsing addict. Unlike his father’s book (also very good) which mingles person narrative with facts in a journalistic memoir, Tweak is all raw emotion and craving.

The Liars’ Club: A Memoir by Mary Karr

You think your mom was crazy? No. Not at all. Mary Karr’s mom? Crazy. As in “let me set your shit on fire and come at you with a knife” crazy. And yet Karr somehow still renders her with empathy and tenderness, describing her childhood in East Texas in this, her first, memoir.

Lit: A Memoir (P.S.) by Mary Karr

If The Liar’s Club let me peer into Mary Karr’s east Texas childhood, Lit, her third memoir, dropped me into her development as an adult and a poet. And consequently into her development as an alcoholic, a recovery alcoholic, and a Catholic (albeit one she describes as “not the Pope’s favorite”). I checked out Lit from the library, read it in a couple days, and then ordered my own copy. So much of the story resonated for me, and Karr’s phrasing and ear for dialogue make it a joy to read.

The Death of American Virtue: Clinton vs. Starr by Ken Gormley

A massive tome at 800 pages, Gormley’s account of Clinton’s legal troubles, beginning with Paula Jones and morphing into the Office of the Independent Council investigation, reads like a novel. Contrary to what I believed in high school, when it was all going on (and I was a Young Republican), as well as what I hear today from some more left-ist friends (that Starr was a rapid attack dog out for blood), Gormley tells a very human story. That is, a story where everyone is flawed, imperfect, and probably underestimating their own flaws. Was Clinton an incorrigible womanizer who caused massive wreckage to his life and the lives of those around him by lying? Yes. Did Starr and his office operate at the edge of their charter, with little oversight or control? Yes. Should you read this? Yes.

Categories: reading.

Tags:

Read: “Django 1.1 Testing and Debugging”, by Karen M. Tracey

Packt Publishing sent me a copy of Django 1.1 Testing and Debugging for review. I was particularly interested in reading this title, as testing is something I know makes my code better, but don’t feel like I do enough of, and because I work on a couple of Django-based projects in my spare time, with varying degrees of test coverage. While I consider myself comfortable with Python’s stock unittest and doctest modules, I was curious to learn about how you can integrate Django with other Python testing tools.

Django 1.1. Testing and Debugging is split, as the title implies, into two halves: Testing, followed by Debugging. It uses a narrative approach, following the development of a survey application throughout. The book starts with an overview of the stock unittest and doctest facilities in Python. Most of chapters 1 through 3 are devoted to the basics of unit testing, specifically for Model classes. Tracey provides information about Django-specific nuances along with way. For example, I didn’t realize Django ships with a customized doctest module to enabled ELLIPSES support in Python 2.3. Chapter 3 also provides information about how to use fixtures for providing test data, and how to specify those apart from the initial data fixtures developers may already be aware of. Chapter 4 mirrors some of the information found in Django’s testing documentation: the Django TestCase, and how you use it to do basic view testing.

Chapter 5 describes integrating Django with other tools, primarily by example. Tracey discusses how to replace the default Django test runner, and what interface the replacement needs to implement. She also provides a stub example of more “invasive” integration, crafting a new management command that could (possibly) handle code coverage reporting while running the tests. This stub was interesting, but didn’t feel particularly testing related to me. Chapter 5 closes with examples of using the excellent coverage package with django-coverage, and integrating twill into Django tests.

Chapter 6 begins the section on debugging with an overview of the Django settings that impact debugging, and how the development server supports debugging of applications. Chapter 7 follows with a thorough analysis of the development server’s error page, as well as examples of debugging based on the information given. The examples continue to develop the survey application, and introduces what Tracey describes as “typical mistakes”, then describes how to fix them.

Chapter 8 begins to dig a little deeper, and I was happy to see mention of Rob Hudson’s Django Debug Toolbar, an indispensable tool. Chapter 8 also includes details on using the logging module, and how to develop a decorator that marks function entry and exit. I know that I’m all too guilty of using print instead of logging, and it was nice to be reminded of how easy this is.

Chapter 9 was my favorite part of the book. It gives a good overview of using pdb, and then goes on to demonstrate how to use pdb and a shell session to test a race condition and deal with it.

Overall Django 1.1 Testing and Debugging seems like a good introductory book for Django developers who are new to testing (or Django). While many of the debugging examples seemed obvious to me, I suspect that someone new to Django could use this book as an introduction to development and debugging.

Categories: reading.

Tags: , , ,

Batteries Included (or, Maildir to mbox, again)

UPDATE 7 June 2010: Added usage information to docstring.

My script for converting maildir to mbox continues to be one of the most popular pages on yergler.net (according to Google Analytics). Of course, even after I updated it slightly in February, it still had a couple of bugs, likely introduced when I converted the page from MoinMoin to WordPress. This afternoon I finally decided to clear out the pending comments about those bugs, and update it.

While looking at the Python documentation for the mailbox package included in the standard library, I realized it could probably be simplified even further by using the library’s native mbox support. I’m also more comfortable using the standard library’s implementation of mbox rather than my hacked up raw file implementation (who knows, the standard library may do exactly what my script did: I’m not an mbox expert by any stretch of the imagination).

The new script is below. I should note that it’s received very little testing, and I make no guarantees. I also should note that there is nothing creative or original about this. It just uses Python’s excellent standard library. As they say, “batteries included”.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
 
"""
maildir2mbox.py
Nathan R. Yergler, 6 June 2010
 
This file does not contain sufficient creative expression to invoke
assertion of copyright.  No warranty is expressed or implied; use at
your own risk.
 
---
 
Uses Python's included mailbox library to convert mail archives from
maildir [http://en.wikipedia.org/wiki/Maildir] to 
mbox [http://en.wikipedia.org/wiki/Mbox] format.
 
See http://docs.python.org/library/mailbox.html#mailbox.Mailbox for 
full documentation on this library.
 
---
 
To run, save as maildir2mbox.py and run:
 
$ python maildir2mbox.py [maildir_path] [mbox_filename]
 
[maildir_path] should be the the path to the actual maildir (containing new, cur, tmp);
 
[mbox_filename] will be newly created.
"""
 
import mailbox
import sys
import email
 
# open the existing maildir and the target mbox file
maildir = mailbox.Maildir(sys.argv [-2], email.message_from_file)
mbox = mailbox.mbox(sys.argv[-1])
 
# lock the mbox
mbox.lock()
 
# iterate over messages in the maildir and add to the mbox
for msg in maildir:
    mbox.add(msg)
 
# close and unlock
mbox.close()
maildir.close()

Categories: geek.

Tags: , ,

Preread: “Django 1.1 Testing and Debugging”, by Karen M. Tracey

Another Packt Publishing title is on the way for review, Django 1.1 Testing and Debugging, by Karen M. Tracey. Django 1.2 ships tomorrow, and I’m looking forward to the book: testing is one of the things that helps software evolve, but it’s also one of the things that’s easiest to ignore on a project. I say this to myself as much as anyone: even though I know tests will make my life better in the long run, when I start hacking, sometimes they’re the furthest thing from my mind. Books about how to test, and how to do it effectively, are definitely a good thing for me.

The PDF preview of chapter 3 (basic unit testing) looks good, and the table of contents looks like a good overview of basic tools and techniques. I’m particularly looking forward to reading about integrating Django with other testing tools (chapter 5), and using Django with pdb (chapter 9). I’m looking forward to learning more about testing my Django applications — and hopefully how I can form better habits around testing.

Categories: reading.

Tags: , ,

WWDC WAG

People put a lot of time and effort into reading the Apple (and Steve J.) tea leaves: what will be announced, when, and will there be “one more thing”? I’ve put next to no time into this, but wanted to document my WAG — wild ass guess — for WWDC this year. I should note: I use a Macbook, but these days Mac OS X is basically a run-time for Firefox for me (my primary machine these days is a Thinkpad running Ubuntu). I use an iPod Color 60GB, and haven’t seen the need to upgrade yet. I haven’t seen an iPad in person. In short, I’m hardly qualified to make predictions about Apple corporate strategy. But that doesn’t seem to stop anyone else.

I believe Apple will announce that you’ll be able to run iPhone OS applications on Mac OS X. Why? Well, it just seems like it fits.

  • Apple is obviously investing heavily in iPhone OS. One indication of its importance is that the Apple Design Awards are limited to iPhone OS applications this year.
  • As the iPad has launched, and developers have been crafting applications to watch video, read news, and listen to public radio, the question has been raised: why weren’t people creating applications that looked this good for laptops? I’m sure people using Macbooks would love to have some of those apps. (I really don’t believe iPhone OS has any secret ingredient that suddenly enables ABC to create a video player.)
  • Apple’s restrictions to the iPhone SDK agreement, prohibiting the use of third party development tools, will allow Apple to easily switch hardware platforms, ala PPC to x86 — or support an additional architecture if needed. You know, an additional architecture like x86.
  • Apple has experience with compatibility virtual machines (see: Rosetta), as well as LLVM. You can imagine these experiences informing support for running iPhone OS applications in a sandbox on Mac OS X, or re-targeting the application at compilation time.
  • Finally, and perhaps most importantly, it inserts Apple into the middle of additional software purchases, enables them to leverage the App Store further, and exert additional control.

So that’s my WAG for WWDC. I think it’ll be sold to developers as a way to reach new users, and provide an end-to-end, mobile to desktop experience (I won’t be surprised if they launch improved, wireless sync between your iPad and Mac at the same time — syncing documents between iWork for iPad and your Mac sounds like hell). I think it’ll be sold to users on security and stability: iPhone OS applications would almost certainly have limited privileges on the desktop, and if you replace your laptop, logging into your iTunes account would sync your apps back to the machine.

If I’m right, users will undoubtedly begin to see [beautiful] software stream onto their desktops from a single, tightly controlled pool, and developers will devote hours crafting tools with the hope they’ll pass muster, and make it into that pool. If I’m wrong, well, I’ve been wrong before. And this is just a wild ass guess.

Categories: geek.

Tags: , , ,