Viewing posts from November, 2013

Combining context managers and decorators for nice DRY Python

I love Python's clarity and expressive power but I recently had a problem where my code was becoming excessively repetitive. In short, I was using an API which may raise a number of exceptions (HttpError, ServerNotResponding…) which I needed to report. Other errors are raised as normal. Thus I had lots of blocks of code looking something like this:

Australia: 07 3103 2894

International: +61 410 545 357