but I don't want to print the trailing ".0"

Dan Bishop danb_83 at yahoo.com
Fri May 2 00:39:52 EDT 2003


Gareth McCaughan <Gareth.McCaughan at pobox.com> wrote in message news:<slrnbb3e6n.on.Gareth.McCaughan at g.local>...
> Dan Jacobson wrote:
 
> > By the way, any dumbness here?:
> > for arg in sys.argv[1:]: #no --help yet, never mind.
> >     freq=string.atof(arg)
> >     remainder=int(round(freq*1000))%9
> >     if not remainder: ...
> > 
> > pydoc string says string.atof is obsolete it seems, oh, I see, I am
> > supposed to use float(), ok, I wish it said that there on pydoc string.
> > How about int(round( ? Looks goofy.
> 
> It's right, whether or not it looks goofy.
> If you mean that round() ought to return an integer,
> then you're probably unaware of the fact that it can
> round to a number of decimal places other than 0. :-)

Which imho isn't incredibly useful when floats aren't decimal.




More information about the Python-list mailing list