Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/build/sage_bootstrap/compat/__init__.py
4081 views
1
# -*- coding: utf-8 -*-
2
"""
3
Python 2/3 compatibility utils
4
"""
5
6
7
#*****************************************************************************
8
# Copyright (C) 2015 Volker Braun <[email protected]>
9
#
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 2 of the License, or
13
# (at your option) any later version.
14
# https://www.gnu.org/licenses/
15
#*****************************************************************************
16
17
18
try:
19
# Python 3
20
import urllib.request as urllib
21
import urllib.parse as urlparse
22
except ImportError:
23
import urllib
24
import urlparse
25
26
27
try:
28
from StringIO import StringIO
29
except ImportError:
30
from io import StringIO
31
32
33
try:
34
# Use this for Python 3. This function is available for Python >= 3.3
35
from shlex import quote
36
except ImportError:
37
# Use this for Python 2. This function is available for Python < 3.13
38
from pipes import quote
39
40