def expand_to_set(X): if isinstance(X, set): return X elif isinstance(X, list): return set(X) elif isinstance(X, type(lambda:0)): return self.selection(X) elif isinstance(X, str): return set(parse_job_list(X)) else: assert False, 'Wrong type %s' % type(X)
def f(s): # it's a generator, you should try to read it return list(parse_job_list(s))