If you want to cut out a third line, you can rewrite the above with a lambda function, which turns four lines into one (how very Pythonesque).