from babel.lists import format_list
format_list(['A', 'B', 'C'], style='standard-narrow', locale='de')
Actual Results
Traceback (most recent call last):
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-fdcd09f7f101>", line 1, in <module>
format_list(['A', 'B', 'C'], style='standard-narrow', locale='de')
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\babel\lists.py", line 82, in format_list
result = patterns['start'].format(lst[0], lst[1])
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\babel\localedata.py", line 218, in __getitem__
orig = val = self._data[key]
KeyError: 'start'
Expected Results
The english locale gives the expected result:
format_list(['A', 'B', 'C'], style='standard-narrow', locale='en')
Out[4]: 'A, B, C'
I believe that standard-narrow isn't a type of style available on babel. The key to fixing this issue might be to use one of the styles listed on their documentation page here.
Revised Code
from babel.lists
import format_list
format_list(['A', 'B', 'C'], style='unit-narrow', locale='de')
Thanks for the reference. I'll do that, but I'm curious as to why the 'standard-narrow' style does work for the English locale, despite it being omitted from the documentation. And in any case there is a gap between the functionality and the documentation that ought to be fixed. Does anyone know why it was implemented that way for English?
Activity
jithenms commented on Apr 24, 2021
I believe that standard-narrow isn't a type of style available on babel. The key to fixing this issue might be to use one of the styles listed on their documentation page here.
Revised Code
from babel.lists
import format_list
format_list(['A', 'B', 'C'], style='unit-narrow', locale='de')
Or
format_list(['A', 'B', 'C'], style='standard', locale='de')
Take a look at their documentation page to see what might fit your use case best.
amelia-bruno commented on Apr 26, 2021
Thanks for the reference. I'll do that, but I'm curious as to why the 'standard-narrow' style does work for the English locale, despite it being omitted from the documentation. And in any case there is a gap between the functionality and the documentation that ought to be fixed. Does anyone know why it was implemented that way for English?