def from_string ( cls , s ) : for num , text in cls . _STATUS2STR . items ( ) : if text == s : return cls ( num ) else : raise ValueError ( "Wrong string %s" % s )
how to change string to object in python
Return a Status instance from its string representation .
def from_string(cls, s):
        """Return a `Status` instance from its string representation."""
        for num, text in cls._STATUS2STR.items():
            if text == s:
                return cls(num)
        else:
            raise ValueError("Wrong string %s" % s)