compat.py 571 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) 2021, Brandon Nielsen
  3. # All rights reserved.
  4. #
  5. # This software may be modified and distributed under the terms
  6. # of the BSD license. See the LICENSE file for details.
  7. import sys
  8. PY2 = sys.version_info[0] == 2
  9. if PY2: # pragma: no cover
  10. range = xrange # pylint: disable=undefined-variable
  11. else:
  12. range = range
  13. def is_string(tocheck):
  14. # pylint: disable=undefined-variable
  15. if PY2: # pragma: no cover
  16. return isinstance(tocheck, str) or isinstance(tocheck, unicode)
  17. return isinstance(tocheck, str)