def obj_or_id(parameter, param_name, object_types):
from canvasapi.user import User<EOL>try:<EOL><INDENT>return int(parameter)<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>if User in object_types and parameter == '<STR_LIT>':<EOL><INDENT>return parameter<EOL><DEDENT>for obj_type in object_types:<EOL><INDENT>if isinstance(parameter, obj_type):<EOL><INDENT>try:<EOL><INDENT>return int(parameter.id)<EOL><DEDENT>except Exception:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>obj_type_list = "<STR_LIT:U+002C>".join([obj_type.__name__ for obj_type in object_types])<EOL>message = '<STR_LIT>'.format(param_name, obj_type_list)<EOL>raise TypeError(message)<EOL><DEDENT>
Accepts either an int (or long or str representation of an integer)
or an object. If it is an int, return it. If it is an object and
the object is of correct type, return the object's id. Otherwise,
throw an exception.

:param parameter: int, str, long, or object
:param param_name: str
:param object_types: tuple
:rtype: int