Is there a way to convert a Python object from one type to another based on the given value?
>>> first = 1 >>> second = '2' >>> type(first) <type 'int'> >>> type(second) <type 'str'> So, I want to convert first to the type of any given second object. I am not really sure how to do this.