locale.delocalize(): only call localeconv() once
This commit is contained in:
parent
bbfcb3895a
commit
2753a096e0
|
@ -303,12 +303,16 @@ def str(val):
|
|||
|
||||
def delocalize(string):
|
||||
"Parses a string as a normalized number according to the locale settings."
|
||||
|
||||
conv = localeconv()
|
||||
|
||||
#First, get rid of the grouping
|
||||
ts = localeconv()['thousands_sep']
|
||||
ts = conv['thousands_sep']
|
||||
if ts:
|
||||
string = string.replace(ts, '')
|
||||
|
||||
#next, replace the decimal point with a dot
|
||||
dd = localeconv()['decimal_point']
|
||||
dd = conv['decimal_point']
|
||||
if dd:
|
||||
string = string.replace(dd, '.')
|
||||
return string
|
||||
|
|
Loading…
Reference in New Issue