Re: locale support and 4.10

2005-03-06 Thread Hye-Shik Chang
On Sat, 05 Mar 2005 15:42:23 +1000, Timothy Smith
<[EMAIL PROTECTED]> wrote:
> i'm trying to setlocale() on 4.10, and it appears the python package
> doesn't support this under 4.10.
> 
> Python 2.3.3 (#2, Apr 28 2004, 22:48:37)
> [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import locale
>  >>> locale.setlocale(locale.LC_NUMERIC, 'us')
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/local/lib/python2.3/locale.py", line 381, in setlocale
> return _setlocale(category, locale)
> locale.Error: unsupported locale setting
>  >>>
> 
> the exact same thing works under windows xp.
> 
> do i have to compile it with locale support?
> 

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, 'us')
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/local/lib/python2.2/locale.py", line 372, in setlocale
return _setlocale(category, locale)
locale.Error: locale setting not supported
>>> locale.setlocale(locale.LC_NUMERIC, 'en_US.ISO8859-1')
'en_US.ISO8859-1'
>>> locale.format('%g', 12.34)
'12.34'
>>> locale.setlocale(locale.LC_NUMERIC, 'fr_FR.ISO8859-1')
'fr_FR.ISO8859-1'
>>> locale.format('%g', 12.34)
'12,34'


You must specify exact locale name in FreeBSD.
eg) en_US.ISO8859-1 en_US.ISO8859-15 or etc.

Hye-Shik
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Possible to import a module whose name is contained in a variable?

2005-03-06 Thread Hye-Shik Chang
On 6 Mar 2005 21:34:08 -0800, Steven Reddie <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I want to do something like the following, which doesn't work:
> 
> modulename = 'module'
> import modulename
> 
> The error is that there is no module named 'modulename'.  Is there a
> way to get that variable expanded?
> 

modulename = 'module'
module = __import__(modulename)


Hye-Shik
-- 
http://mail.python.org/mailman/listinfo/python-list