def stage_id(self): try: return (key for key, value in BILL_STAGES.items() if value == self.stage).next() except StopIteration: return BILL_STAGES['UNKNOWN']