[Tutor] Re: Easy way to print numbers with thousand separators?

emile@fenx.com emile@fenx.com
Fri, 12 May 2000 10:55:12 -0700


John,

This is because your copy of python was compiled without _locale
support.

You'll need to recompile to fix this.  This is how I do it on my RH6
system.
in dist/src/Modules, modify Setup by removing the leading # in the line:

#_locale _localemodule.c # access to ISO C locale support

I update python to the CVS version every couple of weeks.  I've got an
update
script in /usr/src/python that reads:
cvs -z6 -q up -P -d
cd dist/src
make clean
./configure --with-thread --prefix /usr
make
make test
make install

If you've installed the sources, you should be able to recompile
starting
with 'make clean' and on from above.

If recompiling isn't a real option, you'll need to adapt some code to 
do the formatting.  see http://deja.com/getdoc.xp?AN=588167809 for a
start.

HTH,

Emile van Sebille
emile@fenx.com


John Villalovos <john@nwjohn.jf.intel.com> wrote in message
news:<8fh63s$ds8$1@nwjohn.jf.intel.com>...
> Thanks!
> 
> But now when using a Red Hat 6.2 system when I type: import locale
> I get the following:
> 
> Python 1.5.2 (#1, Feb  1 2000, 16:32:16)  [GCC egcs-2.91.66 19990314/Linux\
>  (egcs- on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import locale
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python1.5/locale.py", line 4, in ?
>     from _locale import *
> ImportError: No module named _locale
> >>>
> 
> I can see the locale.py, locale.pyc, & locale.pyo files in /usr/lib/python1.5/
> 
> Is there a configuration file option that will make it work?
> 
> Thanks,
> John
> 
> In article <391B4F36.57EE6313@fenx.com>,  <emile@fenx.com> wrote:
> >>>> import locale
> >>>> locale.setlocale(locale.LC_ALL,"")
> >'English_United States.1252'
> >>>> print locale.format("%12.2f",1234567.89,1)
> >  1,234,567.89
> >
> >Emile van Sebille
> >emile@fenx.com
> >
> >John Villalovos <john@nwjohn.jf.intel.com> wrote in message
> >news:<8ffdtg$dav$1@nwjohn.jf.intel.com>...
> >> I was wondering if there was an easy way to print numbers with thousand
> >> separators in them?
> >> 
> >> For example I want to print the number:  1234567890
> >> 			            as:  1,234,567,890
> >> 
> >> I know I can write a simple little program to do it but I was hoping that there
> >> was already something in the libraries to do this.
> >> 
> >> Thanks,
> >> John
> >> -- 
> >> http://www.python.org/mailman/listinfo/python-list
> >>
> >
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
>