[BangPypers] HELP ON FORMATING OUTPUT

Nanolets nanolets srini at nanolets.in
Sat Mar 22 10:23:16 CET 2008


I was wondering how sri dug out this information.

It turned to be fairly simple. Did a search in python site for
"number formatting", it took me to the tutorial. Brief tour of Standard
Library II
and there it was.

Thinking further  it should have occurred that ofcourse python should have
something for this already and in general it would have something to do with
locale.

Thanks sri

Regards
Srini.



On Sat, Mar 22, 2008 at 12:45 PM, Sribabu <rusticgeek at gmail.com> wrote:

> Hi Jiten
>
> I have probably a easier way via an import.
> here you go:
>
> import locale
>
> def number_format(number, grouping=0):
> return locale.format("%.*f", (grouping, number), True)
>
> regards,
> Sri
>
>
> On Sat, Mar 22, 2008 at 2:10 AM, Nanolets nanolets <srini at nanolets.in>
> wrote:
>
> > A stupid way to do this is
> >
> > x=123456789
> > x=str(x)
> > n=len(x)
> > s=n%3
> > outs=x[0:s]
> > while ( s < n) :
> >        outs = outs + "," + x[s:s+3]
> >        s=s+3
> > print outs
> >
> >
> > On 3/19/08, Jiten Shah <jiten_shah_78 at yahoo.com> wrote:
> > >
> > > Dear Friends,
> > >
> > > I am new for python and new for this mailing list also
> > >
> > > My problem is i want to print
> > >    1156179 to ->   1,156,179.00
> > >
> > > Can somebody help me.
> > >
> > >
> > > Jiten
> > >
> > >
> > >
> > >
> > >
> > >
> > >       ____________________________________________________________________________________
> > > Be a better friend, newshound, and
> > > know-it-all with Yahoo! Mobile.  Try it now.
> > > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> > > _______________________________________________
> > > BangPypers mailing list
> > > BangPypers at python.org
> > > http://mail.python.org/mailman/listinfo/bangpypers
> > >
> >
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> >
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080322/a7e0185c/attachment.htm 


More information about the BangPypers mailing list