def try_enum(cls, val):
<EOL>try:<EOL><INDENT>return cls.__fast_value_lookup__[val]<EOL><DEDENT>except (KeyError, AttributeError):<EOL><INDENT>return val<EOL><DEDENT>
A function that tries to turn the value into enum ``cls``.

    If it fails it returns the value instead.