()
return os.path.expanduser("~" + user)
Get the user's home directory even if running with sudo
Get the user's home directory even if running with sudo
Get the user s home directory even if running with sudo
def get_home_dir():
    """Get the user's home directory even if running with sudo"""
    sudo_user = os.environ.get('SUDO_USER')
    user = sudo_user if sudo_user is not None else ""
    return os.path.expanduser("~" + user)
def get_home_dir ( ) : sudo_user = os . environ . get ( 'SUDO_USER' ) user = sudo_user if sudo_user is not None else "" return os . path . expanduser ( "~" + user )