[Tutor] Some questions about my yen-USD.py
Dick Moores
rdm at rcblue.com
Thu Sep 7 10:33:37 CEST 2006
I've just finished a script for converting Yen to USD, and
vice-versa. A simple, even silly thing to do (a friend asked me to
write it for him--probably just to humor me), but I have tried to
build in some bells and whistles. In doing so, some questions arose.
If some of you Tutors could take look at my script, yen-USD.py, I'd
greatly appreciate it. <http://www.rcblue.com/Python/yen-USD.txt>
My questions:
(1) Have I handled possible user-errors OK?
(2) Is my roundingN() function OK? Is there a better way to write it?
Will the line
n = round(float(n)*(10**rounding))/(10**rounding)
get me into trouble with the flakiness of float(n)? In testing I
didn't find any problems, but ..
(3) Is there a better name for roundingN()? I don't like it, but
can't think of a better one.
(4) I wanted to call closingMessage() in main(), but in some cases,
if it's in main() it gets 2 successive calls. I can't figure out why.
Would IDLE's debugger be of use here? (I've never used it before.) I
haven't been able to find up-to-date IDLE help.
Thanks,
Dick Moores
More information about the Tutor
mailing list