summaryrefslogtreecommitdiffstats
path: root/Lib/locale.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2004-03-23 23:50:17 (GMT)
committerBrett Cannon <bcannon@gmail.com>2004-03-23 23:50:17 (GMT)
commitaaeffaf01e385d9a510f607b0b101ae6ba7dba5b (patch)
tree12d11f87f7d5a314990e15a427e4a283cbeadd1b /Lib/locale.py
parent708b4dacf4f5c24eb30590ace7fb64d0ef018837 (diff)
downloadcpython-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/locale.py')
-rw-r--r--Lib/locale.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index 2028948..192c91f 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -159,18 +159,16 @@ def str(val):
"""Convert float to integer, taking the locale into account."""
return format("%.12g",val)
-def atof(str,func=float):
+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:
- s=str.split(ts)
- str="".join(s)
+ str = str.replace(ts, '')
#next, replace the decimal point with a dot
dd = localeconv()['decimal_point']
if dd:
- s=str.split(dd)
- str='.'.join(s)
+ str = str.replace(dd, '.')
#finally, parse the string
return func(str)