Fredrik Lundh wrote: Hi Fredrik, I apologize if I offended you or have shown any impatience. I shall try again:
> oh, please. urllib.quote is a *function*; there's no way that calling that > function > from code written for urllib2 will affect anything. > > but you can access urllib.quote from the urllib2 namespace too. it's > actually the > very same function: > > >>> urllib.quote > <function quote at 0x00F430F0> > >>> urllib2.quote > <function quote at 0x00F430F0> > > (urllib2 imports lots of stuff from urllib) I dont know, it does not for me. >>> urladd = "http://example.net:[EMAIL PROTECTED]:|\/|pr0c" >>> print urladd http://example.net:[EMAIL PROTECTED]:|\/|pr0c >>>import urllib2 >>> url = urllib2.quote(urladd) Traceback (most recent call last): File "<interactive input>", line 1, in ? AttributeError: 'module' object has no attribute 'quote' >>> import urllib >>> url = urllib.quote(urladd) >>> print url http%3A//example.net%3A80%40username%3A%7C%5C/%7Cpr0c >>> > > I dont want to import urllib, with the urllib2 itself wanted to work > > around this piece of code. > > not wanting to solve a problem is a pretty lousy problem-solving strategy, > really. Sorry. :-) I shall take your advice and try to get to bottom of this issue. - To the piece of code, I import urllib - use urllib.quote() to covert the proxy url to a quoted one. and try again, I get an error: <error> Traceback (most recent call last): File "C:\Python24\forge\ngwallp\ngwall.py", line 38, in ? data = urllib2.urlopen(site) File "C:\Python24\lib\urllib2.py", line 130, in urlopen http://lava.nationalgeographic.com/cgi-bin/pod/wallpaper.cgi?day=13&month=11&year=06 return _opener.open(url, data) File "C:\Python24\lib\urllib2.py", line 358, in open response = self._open(req, data) File "C:\Python24\lib\urllib2.py", line 376, in _open '_open', req) File "C:\Python24\lib\urllib2.py", line 337, in _call_chain result = func(*args) File "C:\Python24\lib\urllib2.py", line 573, in <lambda> lambda r, proxy=url, type=type, meth=self.proxy_open: \ File "C:\Python24\lib\urllib2.py", line 580, in proxy_open if '@' in host: TypeError: iterable argument required </error> This is where, I gave up and wrote the previous email as not to mess up urllib with urllib2. The piece of code, was working properly till I changed my proxy password to something containng '|\/|'. - Before shooting a mail to the grooups, i kindda encoded password to valid url characters ( %7C%5C/%7C) and tried. But this did not work. So, I dont think this is urllib.quote() issue. I am looking for a way as how to use the ProxyHandler with authentication in different way than I have used below. proxy_url_add = r'http://' + proxy_user + ':' + proxy_password + '@' + PROXY_IP proxy_url = urllib.quote(proxy_url_add) proxy_support = urllib2.ProxyHandler({"http":proxy_url}) opener = urllib2.build_opener(proxy_support,urllib2.HTTPHandler) urllib2.install_opener(opener) Thanks for your response. Regards, Senthil -- http://mail.python.org/mailman/listinfo/python-list