def separate_names(names):
    for full_name in names:
        for name in full_name.split(' '):
            yield name

def get_longest(namelist):
    full_names_list = [name.strip() for name in open(namelist)]
    print full_names_list
    full_names = (name.strip() for name in open(namelist))
    print full_names.next()
    names = separate_names(full_names)
    lengths = ((name, len(name)) for name in names)
    return max(lengths, key=lambda x:x[1])

if __name__ == '__main__':
    print get_longest('names.txt')

'''
https://www.lynda.com/Python-tutorials/Using-exercise-files/483228/530089-4.html#tab
'''
