D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Python printing

 

see the comments on this cookbook entry (not the entry itself)

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473872

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, '')
'en_GB.UTF-8'
>>> locale.format("%.*f", (2, 12345678), True)
'12,345,678.00'

D

On Tuesday 04 December 2007 18:21:20 Neil Winchurst wrote:
> On Tue, 4 Dec 2007 10:01:05 +0000
>
> "Ben Goodger" <goodgerster@xxxxxxxxx> wrote:
> > On 04/12/2007, Neil Winchurst <neil@xxxxxxxxxxxxxxxxx> wrote:
> > > I expect it is quite simple, but I cannot find anything to help me.
> > >
> > > Are there any Python experts out there? There must be a way to print
> > > long numbers as for example 1,234,567 instead if 1234567. I just can't
> > > find out how to do this. Or is this beyond the capabilities of Python?
> > > That would surprise me.
> >
> > I found this:
> > http://mail.python.org/pipermail/python-list/2001-February/070494.html
> >
> > Looks rather verbose but seems to do what's needed.
> >
> > --
> > Benjamin F. Goodger
>
> Thanks for that. I have taken out what I need from the program and I
> can now see my integers as I want them. I am surprised that there is no
> module available to do it.
>
> Neil

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html