File: pycompat.py

package info (click to toggle)
python-kgb 7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 532 kB
  • sloc: python: 4,466; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 409 bytes parent folder | download | duplicates (3)
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
"""Python compatibility functions and types."""

from __future__ import unicode_literals

import sys


pyver = sys.version_info[:2]

if pyver[0] == 2:
    text_type = unicode

    def iterkeys(d):
        return d.iterkeys()

    def iteritems(d):
        return d.iteritems()
else:
    text_type = str

    def iterkeys(d):
        return iter(d.keys())

    def iteritems(d):
        return iter(d.items())