Re: Internationalized domain names not working with URLopen
Answer in this topic should help you to solve issue. http://stackoverflow.com/questions/8152161/open-persian-url-domains-with-urllib2?answertab=active#tab-top Regards. 2012/6/13 John Nagle na...@animats.com I'm trying to open http://пример.испытание http://xn--e1afmkfd.xn--80akhbyknj4f with urllib2.urlopen(s1) in Python 2.7 on Windows 7. This produces a Unicode exception: s1 u'http://\u043f\u0440\u0438\**u043c\u0435\u0440.\u0438\** u0441\u043f\u044b\u0442\u0430\**u043d\u0438\u0435' fd = urllib2.urlopen(s1) Traceback (most recent call last): File stdin, line 1, in module File C:\python27\lib\urllib2.py, line 126, in urlopen return _opener.open(url, data, timeout) File C:\python27\lib\urllib2.py, line 394, in open response = self._open(req, data) File C:\python27\lib\urllib2.py, line 412, in _open '_open', req) File C:\python27\lib\urllib2.py, line 372, in _call_chain result = func(*args) File C:\python27\lib\urllib2.py, line 1199, in http_open return self.do_open(httplib.**HTTPConnection, req) File C:\python27\lib\urllib2.py, line 1168, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File C:\python27\lib\httplib.py, line 955, in request self._send_request(method, url, body, headers) File C:\python27\lib\httplib.py, line 988, in _send_request self.putheader(hdr, value) File C:\python27\lib\httplib.py, line 935, in putheader hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values])) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128) The HTTP library is trying to put the URL in the header as ASCII. Why isn't urllib2 handling that? What does urllib2 want? Percent escapes? Punycode? John Nagle -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: return respective values when mutiple keys are passed in dictionary
You can try to use map(mydict.get, ('a', 'b', 'c')) and then make join On May 7, 2012 2:33 PM, Nikhil Verma varma.nikhi...@gmail.com wrote: HI All I was clearing my concepts on dictionary and stuck in this problem. I have a dictionary which i have formed by using zip function on two list so that one list (which i have hardcoded) becomes the keys and the other list becomes its values. Now i want to know how can i get the values of keys at once if i pass the keys in a dictionary. Let say I have a dictionary mydict = {'a':'apple' , 'b':'boy' ,'c' : 'cat', 'd':'duck','e':'egg'} Now if i do :- mydict.get('a') 'apple' What i want is some i pass keys in get and in return i should have all the values of those keys which i pass. ## mydict.get('a','b','c')###demo for what i want 'apple','boy','cat'### Output i want # -- Regards Nikhil Verma +91-958-273-3156 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named gobject
You should install python-gobject 2011/2/21 Luther luther...@gmail.com I recently had to install 2.7.1 from source, and since then, I have been unable to run exaile, which comes with Trisquel 4.0. Here is the error message: Traceback (most recent call last): File /usr/lib/exaile/exaile.py, line 52, in module main() File /usr/lib/exaile/exaile.py, line 49, in main exaile = main.Exaile() File /usr/lib/exaile/xl/main.py, line 74, in __init__ self.mainloop_init() File /usr/lib/exaile/xl/main.py, line 439, in mainloop_init import gobject ImportError: No module named gobject Is there some special way to compile Python? Do I have to install another Debian package? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list