introducing 'mixed', a module providing a class for handling mixed numbers
and fractions.  Parses string and float inputs and handles arithmetic
correctly.

easy_install mixed
development version: hg clone http://hg.assembla.com/mixed_pythonmixed_python
Homepage and trac: http://trac-hg.assembla.com/mixed_python/

>>> from mixed import Mixed
>>> m1 = Mixed('4 2/3')
>>> m2 = Mixed('4/10')
>>> m2.reduced()
Mixed('2/5')
>>> m1 + m2
Mixed('5 1/15')
>>> print m1 / m2
11 2/3
>>> Mixed(-1.5)
Mixed('-1 1/2')
>>> Mixed(2./3.)
Mixed('2/3')

-- 
- Catherine
http://catherinedevlin.blogspot.com/
*** PyCon 2008 * Chicago * March 13-20 * us.pycon.org ***
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

        Support the Python Software Foundation:
        http://www.python.org/psf/donations.html

Reply via email to