"Richard D. Moores" <rdmoo...@gmail.com> wrote

   return ("%%.%sf" % n) % floatt

which works fine, but a question remains: n is an integer. Why the 's'
in '%sf'?

Its arbitrary. You could use %d just as easily.
%s will put the numner into the string, so will %d.
%d is probably a bit more picky about what it inserts - so might
actually be a better choice in this case since

float2n(1.234567, 3.5)

Doesn't work as you might hope... but changing it to use %d might - depending
on your definition of better! And what you might hope! :-)

OTOH %s handles this better:

float2n(1.234567, '3')

maybe...

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to