MCPcopy Index your code
hub / github.com/python/cpython / delocalize

Function delocalize

Lib/locale.py:306–320  ·  view source on GitHub ↗

Parses a string as a normalized number according to the locale settings.

(string)

Source from the content-addressed store, hash-verified

304 return _format("%.12g", val)
305
306def delocalize(string):
307 "Parses a string as a normalized number according to the locale settings."
308
309 conv = localeconv()
310
311 #First, get rid of the grouping
312 ts = conv['thousands_sep']
313 if ts:
314 string = string.replace(ts, '')
315
316 #next, replace the decimal point with a dot
317 dd = conv['decimal_point']
318 if dd:
319 string = string.replace(dd, '.')
320 return string
321
322def localize(string, grouping=False, monetary=False):
323 """Parses a string as locale number according to the locale settings."""

Callers 2

atofFunction · 0.85
atoiFunction · 0.85

Calls 2

localeconvFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…