def _smartcast(castee, caster, subval=None):
try:<EOL><INDENT>return caster(castee)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if caster is float or caster is int:<EOL><INDENT>return nan<EOL><DEDENT>elif caster is str:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return subval<EOL><DEDENT><DEDENT>
This just tries to apply the caster function to castee.

Returns None on failure.