def set_proxy(proxy, user=None, password=''):
 from nltk import compat
 if (proxy is None):
  try:
   proxy = getproxies()['http']
  except KeyError:
   raise ValueError('Could not detect default proxy settings')
 proxy_handler = ProxyHandler({'http': proxy})
 opener = build_opener(proxy_handler)
 if (user is not None):
  password_manager = HTTPPasswordMgrWithDefaultRealm()
  password_manager.add_password(realm=None, uri=proxy, user=user, passwd=password)
  opener.add_handler(ProxyBasicAuthHandler(password_manager))
  opener.add_handler(ProxyDigestAuthHandler(password_manager))
 install_opener(opener)

def set_proxy ( proxy , user = None , password = '' ) : from nltk import compat if ( proxy is None ) : try : proxy = getproxies ( ) [ 'http' ] except KeyError : raise ValueError ( 'Could not detect default proxy settings' ) proxy_handler = ProxyHandler ( { 'http' : proxy } ) opener = build_opener ( proxy_handler ) if ( user is not None ) : password_manager = HTTPPasswordMgrWithDefaultRealm ( ) password_manager . add_password ( realm = None , uri = proxy , user = user , passwd = password ) opener . add_handler ( ProxyBasicAuthHandler ( password_manager ) ) opener . add_handler ( ProxyDigestAuthHandler ( password_manager ) ) install_opener ( opener )
set the http proxy for python to download through .