For detereming the list of available locales see https://phrase.com/blog/posts/beginners-guide-to-locale-in-python/
for lang in locale.locale_alias.values():
print(lang)
You won't be able to "install" anything in the default AWS Lambda Python Runtime Environment and setting up a custom runtime is probably more trouble than it's worth. You can see if there is something else you can use.
If you really are just converting 1.000,00 to 1,000.00 I recommend instead just running your own character replacement. A simple character check loop wouldn't be any slower than atof
and would have less side effects.
If your curious about how atof
works you can follow it's source code trace in https://github.com/python/cpython/blob/3.10/Lib/locale.py#L336
If you don't want to use your own character replace you can use format
with a custom format_spec
.
>>> '{:,.2f}'.format(10000)
'10,000.00'
This next line pretty much follows the same steps at atof
. Delocalize with replacements then float.
>>> '{:,.2f}'.format(float('10.000,00'.replace('.','').replace(',','.')))
'10,000.00'
https://docs.python.org/3/library/functions.html#format
https://docs.python.org/3/library/string.html#formatspec
If you you really want to customize your lambda runtime see the following:
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html