1# encoding: utf-8 2""" 3This module provides compatibility between Python 2 and 3. Hardly 4anything is used by this project to constitute including `six`_. 5 6.. _`six`: http://pythonhosted.org/six 7""" 8 9import sys 10 11if sys.version_info[0] < 3: 12 # Python 2. 13 unicode = unicode 14 string_types = (basestring,) 15 16 from itertools import izip_longest 17 18 def iterkeys(mapping): 19 return mapping.iterkeys() 20 21else: 22 # Python 3. 23 unicode = str 24 string_types = (unicode,) 25 26 from itertools import zip_longest as izip_longest 27 28 def iterkeys(mapping): 29 return mapping.keys() 30 31try: 32 # Python 3.6+. 33 from collections.abc import Collection as collection_type 34except ImportError: 35 # Python 2.7 - 3.5. 36 from collections import Container as collection_type 37