how to convert class string to dict python