Print twitter errors
[rainbowstream.git] / rainbowstream / py3patch.py
CommitLineData
c3bab4ef 1import sys
2
95baa044 3# Library compatibility
3f6bfc20 4if sys.version[0] == "2":
b2cde062 5 from HTMLParser import HTMLParser
a65129d4 6 from urllib2 import URLError
3f6bfc20
O
7else:
8 from html.parser import HTMLParser
a65129d4
O
9 from urllib.error import URLError
10
3f6bfc20
O
11unescape = HTMLParser().unescape
12# According to https://github.com/python/cpython/blob/master/Lib/html/parser.py#L547 ,
13# in python 3.5 maybe I should use
14# from html import unescape
15# but it is a far-future story:)
b2cde062 16
95baa044
O
17
18# Function compatibility
19# xrange, raw_input, map ,unicde
3f6bfc20
O
20if sys.version[0] == "2":
21 lmap = lambda f, a: map(f, a)
7c437a0f
O
22 str2u = lambda x: x.decode('utf-8')
23 u2str = lambda x: x.encode('utf-8')
3f6bfc20 24else:
13e6b275 25 xrange = range
c3bab4ef 26 raw_input = input
422dd385 27 lmap = lambda f, a: list(map(f, a))
7c437a0f 28 str2u = u2str = lambda x: x