diff options
author | Brett Cannon <bcannon@gmail.com> | 2004-03-23 23:50:17 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2004-03-23 23:50:17 (GMT) |
commit | aaeffaf01e385d9a510f607b0b101ae6ba7dba5b (patch) | |
tree | 12d11f87f7d5a314990e15a427e4a283cbeadd1b /Lib/urllib.py | |
parent | 708b4dacf4f5c24eb30590ace7fb64d0ef018837 (diff) | |
download | cpython-aaeffaf01e385d9a510f607b0b101ae6ba7dba5b.zip cpython-aaeffaf01e385d9a510f607b0b101ae6ba7dba5b.tar.gz cpython-aaeffaf01e385d9a510f607b0b101ae6ba7dba5b.tar.bz2 |
Replace sequential split/join calls on strings with a single replace call.
Thanks Andrew Gaul.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 1e633d8..8234296 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -169,9 +169,7 @@ class URLopener: proxy = None name = 'open_' + urltype self.type = urltype - if '-' in name: - # replace - with _ - name = '_'.join(name.split('-')) + name = name.replace('-', '_') if not hasattr(self, name): if proxy: return self.open_unknown_proxy(proxy, fullurl, data) @@ -1045,9 +1043,7 @@ def unquote(s): def unquote_plus(s): """unquote('%7e/abc+def') -> '~/abc def'""" - if '+' in s: - # replace '+' with ' ' - s = ' '.join(s.split('+')) + s = s.replace('+', ' ') return unquote(s) always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' |