def read_g_char(in_name, pop='ESP', debug=False):
    """
    Read charges and energy from a Gaussian log file.

    Parameters
    ----------
    in_name : str
        Name of the file to read
    pop : str, optional
        Kind of charge to read, mulliken or esp
    debug : bool, optional
        Return extra energy information. Turn on with care
    Returns
    -------
    charges : list of floats
        Each partial charge value in the file
    energy : float
        Gaussian calculated energy in Hartree
    char_ener : float
        Self energy of the point charges
    n_char : float
        Nuclei-charge interaction energy

    """
    with open(in_name) as gauss_file:
        content = gauss_file.readlines()
    if pop.lower() == 'mulliken':
        last_mull = len(content) - 1 - content[::-1].index(
            ' Mulliken charges:\n')
    elif pop.lower() == 'esp' or pop.lower() == 'resp':
        last_mull = len(content) - 1 - content[::-1].index(' ESP charges:\n')
    charges = []
    for line in content[last_mull + 2:]:
        if line.split()[0].isdigit():
            charges.append(float(line.split()[2]))
        else:
            break
    for line in content:
        if 'SCF Done' in line:
            energy = float(line.split()[4])
        if 'Total Energy' in line:
            energy = float(line.split()[4])
        if 'Self energy of the charges' in line:
            char_ener = float(line.split()[6])
        if 'Nuclei-charges interaction' in line:
            n_char = float(line.split()[3])
    if debug:
        return charges, energy, char_ener, n_char
    else:
        return charges, energy
