This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: locale.D_* and .T_* are int, not string
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 3.0, Python 3.1, Python 2.6, Python 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: amaury.forgeotdarc, georg.brandl, jonash, r.david.murray
Priority: normal Keywords:

Created on 2009-07-10 10:27 by jonash, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg90384 - (view) Author: Jonas H. (jonash) * Date: 2009-07-10 10:27
The locale.D_* and locale.T_* attributes are ints with weird values
instead of strings (see documentation[1]).


>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US.utf8')
>>> locale.D_T_FMT
>>> locale.D_FMT
>>> locale.T_FMT
>>> locale.T_FMT_AMPM

It seems like the .DAY_* stuff is also broken:
>>> locale.DAY_1
>>> locale.DAY_2
>>> locale.DAY_7

And many other variables:
>>> locale.THOUSEP

The documentation says that every of these variables should be strings.


msg90386 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-10 10:52
If you look a little further up in the page you will see:

"The nl_langinfo() function accepts one of the following keys. Most
descriptions are taken from the corresponding description in the GNU C

I agree that the descriptions of the constants are a bit confusing, but
the fact that it says "return" instead of saying that it is _is_ a
string should be a clue that the item itself is not a string. 

A doc patch would certainly be considered if you see a way to make it
more obvious.
msg90387 - (view) Author: Jonas H. (jonash) * Date: 2009-07-10 11:09
I would suggest to make those constants be strings. There's no need for
those int values; in most cases, you want the strings and not the int

Until then, I would put that nl_langinfo() stuff in a warning or info
box (or highlight it somehow differently).

msg90388 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-10 11:35
The description of each of these constants could start like this:
When passed to :func:`nl_langinfo`, return a string ...

+ the "Example:" paragraph should be moved in a more prominent place,
near the top of the file for example.
msg90395 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-10 20:30
They can't be static string constants because they aren't constants. 
They depend on the current locale settings.

I'm reopening this as a doc bug.
msg90415 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 10:51
I moved the constants' description into the nl_langinfo() description
and clarified their use in r73945.
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50705
2009-07-11 10:51:58georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90415
2009-07-10 20:30:27r.david.murraysetstatus: closed -> open

assignee: georg.brandl
components: + Documentation, - Library (Lib)

nosy: + georg.brandl
messages: + msg90395
resolution: not a bug -> (no value)
stage: resolved -> needs patch
2009-07-10 11:35:29amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg90388
2009-07-10 11:09:54jonashsetmessages: + msg90387
2009-07-10 10:52:35r.david.murraysetstatus: open -> closed
priority: normal

nosy: + r.david.murray
messages: + msg90386
resolution: not a bug
stage: resolved
2009-07-10 10:27:35jonashcreate