def is_type(obj, typestr_or_type):
if typestr_or_type == "<STR_LIT:all>":<EOL><INDENT>return True<EOL><DEDENT>if type(typestr_or_type) == types.TypeType:<EOL><INDENT>test_type = typestr_or_type<EOL><DEDENT>else:<EOL><INDENT>test_type = typestr2type.get(typestr_or_type, False)<EOL><DEDENT>if test_type:<EOL><INDENT>return isinstance(obj, test_type)<EOL><DEDENT>return False<EOL>
is_type(obj, typestr_or_type) verifies if obj is of a certain type. It
    can take strings or actual python types for the second argument, i.e.
    'tuple'<->TupleType. 'all' matches all types.

    TODO: Should be extended for choosing more than one type.