import grp


def get_group_from_gid(gid):
    """Return group name from GID

    Looks up group name matching the supplied GID;
    returns None if no matching name can be found.

    """
    try:
        return grp.getgrgid(int(gid)).gr_name
    except (KeyError,ValueError,OverflowError):
        return None