Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2753a09

Browse files
committed
locale.delocalize(): only call localeconv() once
1 parent bbfcb38 commit 2753a09

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/locale.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,16 @@ def str(val):
303303

304304
def delocalize(string):
305305
"Parses a string as a normalized number according to the locale settings."
306+
307+
conv = localeconv()
308+
306309
#First, get rid of the grouping
307-
ts = localeconv()['thousands_sep']
310+
ts = conv['thousands_sep']
308311
if ts:
309312
string = string.replace(ts, '')
313+
310314
#next, replace the decimal point with a dot
311-
dd = localeconv()['decimal_point']
315+
dd = conv['decimal_point']
312316
if dd:
313317
string = string.replace(dd, '.')
314318
return string

0 commit comments

Comments
 (0)