Thursday, February 28, 2008

Introducing Mixed

As far as I know, the Cheese Shop didn't have any way to handle fractions and mixed numbers... until now. Introducing mixed.
>>> print Mixed('-1 1/2') + 2
1/2
>>> print Mixed('3/4') + Mixed('1/2')
1 1/4
>>> print Mixed('-1-1/4') * 2
-2 1/2

You'll feel like you're in second grade all over again!

easy_install mixed to get it.

I hosted the code on Assembla, which has free mercurial repository hosting, so anybody who wants to polish it up is welcome to! hg clone http://hg.assembla.com/mixed_python mixed_python gets you a copy of the repository.

And all this because I was importing into a table last night and noticed some mixed numbers. A normal human being would have just converted them to floats in her head and gone to bed...

1 comment:

Anonymous said...

You'd better put a link on the PyPI page, not everyone is curious enough to look for "Catherine Devlin" in a search engine.