Commit | Line | Data |
---|---|---|
c3bab4ef | 1 | """ |
2 | Python 3 supports | |
3 | """ | |
4 | import sys | |
5 | ||
6 | # StringIO module | |
7 | try: | |
77f1d210 | 8 | from StringIO import StringIO, BytesIO |
c3bab4ef | 9 | except: |
77f1d210 | 10 | from io import StringIO, BytesIO |
c3bab4ef | 11 | |
b2cde062 | 12 | # HTMLParser module |
3f6bfc20 | 13 | if sys.version[0] == "2": |
b2cde062 | 14 | from HTMLParser import HTMLParser |
3f6bfc20 O |
15 | else: |
16 | from html.parser import HTMLParser | |
17 | unescape = HTMLParser().unescape | |
18 | # According to https://github.com/python/cpython/blob/master/Lib/html/parser.py#L547 , | |
19 | # in python 3.5 maybe I should use | |
20 | # from html import unescape | |
21 | # but it is a far-future story:) | |
b2cde062 | 22 | |
b13c6a0d | 23 | # raw_input and map function behaviour |
3f6bfc20 O |
24 | if sys.version[0] == "2": |
25 | lmap = lambda f, a: map(f, a) | |
612d6863 | 26 | unc = lambda x: x.decode('utf-8') |
3f6bfc20 | 27 | else: |
13e6b275 | 28 | xrange = range |
c3bab4ef | 29 | raw_input = input |
422dd385 | 30 | lmap = lambda f, a: list(map(f, a)) |
612d6863 | 31 | unc = lambda x: x |