Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

"""Compatibility between Py2 and Py3.""" 

 

import sys 

 

PY3 = sys.version_info[0] == 3 

 

8if PY3: 

    string_types = (str,bytes) 

    text_types = (str,) 

    bytes_types = (bytes,) 

    def b(s): 

        return s.encode("latin-1") 

    def u(s): 

        return s 

    def to_bytes(s): 

        return s.encode('utf8') 

else: 

    string_types = (basestring,) 

    text_types = (unicode,) 

    bytes_types = (str,) 

    def b(s): 

        return s 

    def u(s): 

        return unicode(s, "unicode_escape") 

    def to_bytes(s): 

        return s 

 

# Pythons 2 and 3 differ on where to get StringIO 

try: 

    from cStringIO import StringIO 

except ImportError: 

    from io import StringIO