import gzip


def gz_open(fn, mode='r'):
    """Open file with io.open() or gzip.open().

    :param str fn: Name of the file to open.
    :param char md: Mode '**r**' | 'w'.

    """
    if fn[-2:] == "gz":
        fo = gzip.open(fn, mode=mode+'t')
    else:
        fo = open(fn, mode=mode)
    return fo