Python doesn't use decimal point separator in 'Region and language'
up vote
1
down vote
favorite
If I open the 'Region and language' dialog, I have 'Formats' set to 'Germany'. If I click that setting, the 'Numbers' preview is '123.456.789,00' (comma as a decimal separator).
But if I run python3 -c 'import locale; print(locale.localeconv()["decimal_point"])'
, it outputs .
(a dot, not a comma).
How can I get the decimal point as configured by the user in the 'Region and language' dialog?
python system-settings internationalization gettext
add a comment |
up vote
1
down vote
favorite
If I open the 'Region and language' dialog, I have 'Formats' set to 'Germany'. If I click that setting, the 'Numbers' preview is '123.456.789,00' (comma as a decimal separator).
But if I run python3 -c 'import locale; print(locale.localeconv()["decimal_point"])'
, it outputs .
(a dot, not a comma).
How can I get the decimal point as configured by the user in the 'Region and language' dialog?
python system-settings internationalization gettext
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
If I open the 'Region and language' dialog, I have 'Formats' set to 'Germany'. If I click that setting, the 'Numbers' preview is '123.456.789,00' (comma as a decimal separator).
But if I run python3 -c 'import locale; print(locale.localeconv()["decimal_point"])'
, it outputs .
(a dot, not a comma).
How can I get the decimal point as configured by the user in the 'Region and language' dialog?
python system-settings internationalization gettext
If I open the 'Region and language' dialog, I have 'Formats' set to 'Germany'. If I click that setting, the 'Numbers' preview is '123.456.789,00' (comma as a decimal separator).
But if I run python3 -c 'import locale; print(locale.localeconv()["decimal_point"])'
, it outputs .
(a dot, not a comma).
How can I get the decimal point as configured by the user in the 'Region and language' dialog?
python system-settings internationalization gettext
python system-settings internationalization gettext
edited Nov 26 at 16:08
wjandrea
8,05142258
8,05142258
asked Nov 26 at 15:58
Janus Troelsen
2,1141620
2,1141620
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You need to run locale.setlocale()
too.
python3 -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print(locale.localeconv()["decimal_point"])'
This simply adopts whatever is inLC_ALL
. On my system, somehow all the variables reported bylocale
are not de_DE even though Germany is selected as mentioned.
– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of thelocale
command). If you switched to German as Format in the current session, you need to relogin to have theLC_NUMERIC
variable (which affects the decimal separator) updated.
– Gunnar Hjalmarsson
Nov 26 at 21:00
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You need to run locale.setlocale()
too.
python3 -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print(locale.localeconv()["decimal_point"])'
This simply adopts whatever is inLC_ALL
. On my system, somehow all the variables reported bylocale
are not de_DE even though Germany is selected as mentioned.
– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of thelocale
command). If you switched to German as Format in the current session, you need to relogin to have theLC_NUMERIC
variable (which affects the decimal separator) updated.
– Gunnar Hjalmarsson
Nov 26 at 21:00
add a comment |
up vote
1
down vote
accepted
You need to run locale.setlocale()
too.
python3 -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print(locale.localeconv()["decimal_point"])'
This simply adopts whatever is inLC_ALL
. On my system, somehow all the variables reported bylocale
are not de_DE even though Germany is selected as mentioned.
– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of thelocale
command). If you switched to German as Format in the current session, you need to relogin to have theLC_NUMERIC
variable (which affects the decimal separator) updated.
– Gunnar Hjalmarsson
Nov 26 at 21:00
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You need to run locale.setlocale()
too.
python3 -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print(locale.localeconv()["decimal_point"])'
You need to run locale.setlocale()
too.
python3 -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print(locale.localeconv()["decimal_point"])'
answered Nov 26 at 17:31
Gunnar Hjalmarsson
18.9k23261
18.9k23261
This simply adopts whatever is inLC_ALL
. On my system, somehow all the variables reported bylocale
are not de_DE even though Germany is selected as mentioned.
– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of thelocale
command). If you switched to German as Format in the current session, you need to relogin to have theLC_NUMERIC
variable (which affects the decimal separator) updated.
– Gunnar Hjalmarsson
Nov 26 at 21:00
add a comment |
This simply adopts whatever is inLC_ALL
. On my system, somehow all the variables reported bylocale
are not de_DE even though Germany is selected as mentioned.
– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of thelocale
command). If you switched to German as Format in the current session, you need to relogin to have theLC_NUMERIC
variable (which affects the decimal separator) updated.
– Gunnar Hjalmarsson
Nov 26 at 21:00
This simply adopts whatever is in
LC_ALL
. On my system, somehow all the variables reported by locale
are not de_DE even though Germany is selected as mentioned.– Janus Troelsen
Nov 26 at 20:31
This simply adopts whatever is in
LC_ALL
. On my system, somehow all the variables reported by locale
are not de_DE even though Germany is selected as mentioned.– Janus Troelsen
Nov 26 at 20:31
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of the
locale
command). If you switched to German as Format in the current session, you need to relogin to have the LC_NUMERIC
variable (which affects the decimal separator) updated.– Gunnar Hjalmarsson
Nov 26 at 21:00
@JanusTroelsen: No, it imports all the locale categories which are currently effective (i.e. in accordance with the output of the
locale
command). If you switched to German as Format in the current session, you need to relogin to have the LC_NUMERIC
variable (which affects the decimal separator) updated.– Gunnar Hjalmarsson
Nov 26 at 21:00
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1096218%2fpython-doesnt-use-decimal-point-separator-in-region-and-language%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown