def password_from_netrc(machine, user):
    '''Given a machine name and user name, return the associated password in
    ~/.netrc. Returns None if not found or if .netrc does not exist.'''
    password = None
    try:
        auth = netrc.netrc().authenticators(machine)
        if auth and auth[0] == user:
            password = auth[2]
    except IOError:
        pass
    return password
Given a machine name and user name, return the associated password in
    ~/.netrc. Returns None if not found or if .netrc does not exist.
recipes/Python/572207_Using_Pexpect_netrc_automate_commands_which/recipe-572207.py