[Baypiggies] Currency to Words or how to print checks...
Eric Walstad
eric at ericwalstad.com
Sun Jan 9 20:29:00 CET 2011
Hi Paul,
On Tue, Jan 4, 2011 at 10:48 PM, Paul Ivanov <pivanov314 at gmail.com> wrote:
> Eric Walstad, on 2011-01-04 21:56, wrote:
>> I found pynum2word on SF[1] which looks promising with nice
>> looking code...
> In [11]: def correct_cents(num,s):
> ....: s = s[:s.index("point")]
> ....: s += "and %d/100" % int(num*100%100)
> ....: return s
> ....:
>
>
> In [12]: correct_cents(1234.56,'one thousand, two hundred and thirty-four point five five')
> Out[12]: 'one thousand, two hundred and thirty-four and 56/100'
I decided to stick with pynum2word, tweaking it a bit to add a
to_check method which does something similar to your suggestion,
above. I wanted the 'and' only between the dollars and cents so I
made that change, too. The first checks came out of the printer on
Friday. Yippee, no more hand written checks!
Eric.
More information about the Baypiggies
mailing list