Probably better as `course_id = getattr(self, 'course_id', '')`. Then you don't need the overly broad `except`.