Elementary string-formatting

Roberto Bonvallet rbonvall at gmail.com
Sun Jan 13 07:34:49 CET 2008


On Jan 12, 10:15 pm, Odysseus <odysseus1479... at yahoo-dot.ca> wrote:
> P.S. Is there a preferable technique for forcing floating-point division
> of two integers to that used above, multiplying by "100.0" first?

Put this at the beginning of your program:

    from __future__ import division

This forces all divisions to yield floating points values:

    >>> 1/3
    0
    >>> from __future__ import division
    >>> 1/3
    0.33333333333333331
    >>>

HTH,
--
Roberto Bonvallet



More information about the Python-list mailing list