Fixing some non-idiomatic python code.

Signed-off-by: Joe Buck <jbbuck@gmail.com>