pyqtgraph/pyqtgraph/python2_3.py
Kenneth Lyons faef56c3e7 Qulogic py3 fixes (#1073)
* py3k: Remove reduce calls.

* py3k: Remove compatibility sortList function.

Sorting by key has existed since Python 2.4.

* Remove unnecessary sys.path manipulation.

This file doesn't have any __main__ code to run anyway.

* Use context manager
2019-11-12 08:45:42 -08:00

26 lines
542 B
Python

# -*- coding: utf-8 -*-
"""
Helper functions that smooth out the differences between python 2 and 3.
"""
import sys
def asUnicode(x):
if sys.version_info[0] == 2:
if isinstance(x, unicode):
return x
elif isinstance(x, str):
return x.decode('UTF-8')
else:
return unicode(x)
else:
return str(x)
if sys.version_info[0] == 3:
basestring = str
xrange = range
else:
import __builtin__
basestring = __builtin__.basestring
xrange = __builtin__.xrange