<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pairwise(args):
 """ %prog pairwise ids Convert a list of IDs into all pairs. """

    from itertools import combinations

    p = OptionParser(pairwise.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    idsfile, = args
    ids = SetFile(idsfile)
    ids = sorted(ids)
    fw = open(idsfile + ".pairs", "w")
    for a, b in combinations(ids, 2):
        print("\t".join((a, b)), file=fw)
    fw.close()