[Python-checkins] python/dist/src/Lib locale.py, 1.25,
1.26 urllib.py, 1.161, 1.162
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Tue Mar 23 18:50:19 EST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7115/Lib
Modified Files:
locale.py urllib.py
Log Message:
Replace sequential split/join calls on strings with a single replace call.
Thanks Andrew Gaul.
Index: locale.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** locale.py 30 Mar 2003 15:42:13 -0000 1.25
--- locale.py 23 Mar 2004 23:50:16 -0000 1.26
***************
*** 160,175 ****
return format("%.12g",val)
! def atof(str,func=float):
"Parses a string as a float according to the locale settings."
#First, get rid of the grouping
ts = localeconv()['thousands_sep']
if ts:
! s=str.split(ts)
! str="".join(s)
#next, replace the decimal point with a dot
dd = localeconv()['decimal_point']
if dd:
! s=str.split(dd)
! str='.'.join(s)
#finally, parse the string
return func(str)
--- 160,173 ----
return format("%.12g",val)
! def atof(string,func=float):
"Parses a string as a float according to the locale settings."
#First, get rid of the grouping
ts = localeconv()['thousands_sep']
if ts:
! str = str.replace(ts, '')
#next, replace the decimal point with a dot
dd = localeconv()['decimal_point']
if dd:
! str = str.replace(dd, '.')
#finally, parse the string
return func(str)
Index: urllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v
retrieving revision 1.161
retrieving revision 1.162
diff -C2 -d -r1.161 -r1.162
*** urllib.py 23 Mar 2004 21:26:39 -0000 1.161
--- urllib.py 23 Mar 2004 23:50:17 -0000 1.162
***************
*** 170,176 ****
name = 'open_' + urltype
self.type = urltype
! if '-' in name:
! # replace - with _
! name = '_'.join(name.split('-'))
if not hasattr(self, name):
if proxy:
--- 170,174 ----
name = 'open_' + urltype
self.type = urltype
! name = name.replace('-', '_')
if not hasattr(self, name):
if proxy:
***************
*** 1046,1052 ****
def unquote_plus(s):
"""unquote('%7e/abc+def') -> '~/abc def'"""
! if '+' in s:
! # replace '+' with ' '
! s = ' '.join(s.split('+'))
return unquote(s)
--- 1044,1048 ----
def unquote_plus(s):
"""unquote('%7e/abc+def') -> '~/abc def'"""
! s = s.replace('+', ' ')
return unquote(s)
More information about the Python-checkins
mailing list