Serhiy Storchaka added the comment: I would write just: if isinstance(code, HTTPStatus): code = '%d' % code ---------- _______________________________________ Python tracker <report at bugs.python.org> <http://bugs.python.org/issue21793> _______________________________________