[Tutor] Some questions about my yen-USD.py

Amadeo Bellotti amadeo.bellotti at gmail.com
Mon Sep 18 04:10:20 CEST 2006


ok i jsut wanted to say great program but i would like to see an acutal
exchange rate like maybe get it from a website it would be so much nicer and
easier to use also it would help linux users who run from console so they
dont have to look up the current rate online

On 9/17/06, Dick Moores <rdm at rcblue.com> wrote:
>
> I'm baaaack!
>
> I kept getting ideas for what I (and some of you) thought was a
> finished yen-USD.py. And some of the good advice I got was to move on
> to other things. I did for a while, but I kept thinking up new
> revisions. The script has more than doubled in length. I'd previously
> posted v4 at <http://www.rcblue.com/Python/yen-USD-v3.txt>.
>
> Here's v10: <http://www.rcblue.com/Python/yen-USD-v10.txt>
>
> New functions:
> again()
> divide2StringDecimals()
> multiply2StringDecimals()
> roundNumber() -- replaced setPrecision()
> printVariablesNotChanging()
> formatNumber()
> removeCommasFromNumbers()
>
> rather radically revised function:
> again()  -- offers several more choices
>
> The most important change is that because I realized I wanted the
> program to be a general solution and give accurate answers for even
> very large amounts of Yen or USD, I decided to operate with (number)
> strings only, except when necessary in getRate() and getAmount() to
> error check user inputs. Those floats are not used in the
> calculations of Yen or USD.
>
> The most difficult function for me to write was roundNumber(), which
> of course couldn't rely on the use of the built-in round() or the
> formatting of strings (see the line "format = "%." + str(precision) +
> 'f'" in setPrecision() in v3).  Lack of experience with the slicing
> of lists caused many headaches. I didn't succeed in debugging until I
> put in print statements wherever a value changes, and trying many
> different integer strings and places (the arguments of
> roundNumber()). A good lesson, I think.
>
> I hope some of the Tutors will take a look at the new functions,
> especially roundNumber().
> Did I just reinvent the wheel?
> Should it be broken up into more sub-functions (there's only one now)?
> It works, but is it Pythonic? Etc.
>
> I'm also curious about multiply2StringDecimals() and
> divide2StringDecimals().
> Again, am I reinventing the wheel with these?
> Is there a simpler way to multiply and divide big decimals with precision?
>
> Thanks in advance,
>
> Dick Moores
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060917/2be7b7bb/attachment-0001.html 


More information about the Tutor mailing list