def str_to_num(i, exact_match=True):
<EOL>if not isinstance(i, str):<EOL><INDENT>return i<EOL><DEDENT>try:<EOL><INDENT>if not exact_match:<EOL><INDENT>return int(i)<EOL><DEDENT>elif str(int(i)) == i:<EOL><INDENT>return int(i)<EOL><DEDENT>elif str(float(i)) == i:<EOL><INDENT>return float(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>return i<EOL>
Attempts to convert a str to either an int or float