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

2006-09-18 Thread Amadeo Bellotti
thats fine its just my dad would need that and it would be easier for him if he had the exchange rate bulit inOn 9/17/06, Dick Moores < [EMAIL PROTECTED]> wrote:At 07:10 PM 9/17/2006, Amadeo Bellotti wrote:>ok i jsut wanted to say great program but i would like to see an >acutal exchange rate like

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

2006-09-18 Thread Alan Gauld
>>> And what's the downside of the way I've done it? >> >> Its slow... > > Actually it is not particularly slow. The actual function code is > created once, when the module is compiled; creating a function > object and binding it to a name is pretty fast. There is a good > discussion here: > htt

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

2006-09-18 Thread Dick Moores
At 06:56 AM 9/18/2006, Luke Paireepinart wrote: >Dick Moores wrote: >>At 05:20 AM 9/18/2006, Kent Johnson wrote: >> >> >>>You have greatly underused Decimal - it is capable of multiplication and >>>division of fractional quantities directly: >>> >>>In [1]: from decimal import Decimal as D >>> >>>In

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

2006-09-18 Thread Luke Paireepinart
Dick Moores wrote: > At 05:20 AM 9/18/2006, Kent Johnson wrote: > > >> You have greatly underused Decimal - it is capable of multiplication and >> division of fractional quantities directly: >> >> In [1]: from decimal import Decimal as D >> >> In [2]: x=D('1.23') >> >> In [3]: y=D('4.5') >> >> I

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

2006-09-18 Thread Luke Paireepinart
Dick Moores wrote: > At 01:00 AM 9/18/2006, Alan Gauld wrote: > 1. in your roundNumber function, you define a function incrementDigit. I'm pretty sure that this function is destroyed and recreated every time you call the function roundNumber. >>> I don't

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

2006-09-18 Thread Dick Moores
At 05:20 AM 9/18/2006, Kent Johnson wrote: >You have greatly underused Decimal - it is capable of multiplication and >division of fractional quantities directly: > >In [1]: from decimal import Decimal as D > >In [2]: x=D('1.23') > >In [3]: y=D('4.5') > >In [4]: x*y >Out[4]: Decimal("5.535") > >In

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

2006-09-18 Thread Dick Moores
At 01:00 AM 9/18/2006, Alan Gauld wrote: > >> 1. in your roundNumber function, you define a function > >> incrementDigit. > >> I'm pretty sure that this function is destroyed and recreated > >> every time > >> you call the function roundNumber. > > I don't understand. What's another way? > >def

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

2006-09-18 Thread Kent Johnson
Alan Gauld wrote: >>> 1. in your roundNumber function, you define a function >>> incrementDigit. >>> I'm pretty sure that this function is destroyed and recreated >>> every time >>> you call the function roundNumber. >> I don't understand. What's another way? > > def f(): > def g(): retur

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

2006-09-18 Thread Kent Johnson
Dick Moores wrote: > I'm bck! > > 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.

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

2006-09-18 Thread Alan Gauld
>> 1. in your roundNumber function, you define a function >> incrementDigit. >> I'm pretty sure that this function is destroyed and recreated >> every time >> you call the function roundNumber. > I don't understand. What's another way? def f(): def g(): return 42 return g() def g():

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

2006-09-18 Thread Dick Moores
At 08:13 PM 9/17/2006, Luke Paireepinart wrote: Dick Moores wrote: > I'm bck! > > 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 > revis

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

2006-09-17 Thread Luke Paireepinart
Dick Moores wrote: > I'm bck! > > 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.

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

2006-09-17 Thread Dick Moores
At 07:10 PM 9/17/2006, Amadeo Bellotti wrote: >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 th

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

2006-09-17 Thread Amadeo Bellotti
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 <[EMAIL

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

2006-09-17 Thread Dick Moores
I'm bck! 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 <

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

2006-09-08 Thread Alan Gauld
> Alan Gauld wrote: >> unfortunately 3 values won't work, it only works for numbers... >> > "%**.*" % ('-', 12,3,123.456789) >> >> Error... > > How about this: > In [4]: "%*.*f" % (-12,3,123.456789) > Out[4]: '123.457 ' Silly me! Obvious when you see it :-) Alan G. ___

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

2006-09-08 Thread Kent Johnson
Alan Gauld wrote: > unfortunately 3 values won't work, it only works for numbers... > "%**.*" % ('-', 12,3,123.456789) > > Error... How about this: In [4]: "%*.*f" % (-12,3,123.456789) Out[4]: '123.457 ' Kent ___ Tutor maillist - Tutor@pyt

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

2006-09-08 Thread Alan Gauld
> http://www.python.org/doc/current/lib/typesseq-strings.html > "%.*f" % (2, 2.234234) > '2.23' Cool! I'd never noticed this, or maybe just difdn't understand the significance. And it works for multiple values too: >>> "%*.*" % (12,3,123.456789) unfortunately 3 values won't work, it only

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

2006-09-08 Thread Andrei
Dick Moores rcblue.com> writes: > Version 3 is now at http://www.rcblue.com/Python/yen-USD-v3.txt . Am > I done? Or will a v4 be necessary/advisable? The original program worked fine from the user's POV and the code had lots of good features (functions instead of monolithic code, docstrings). I

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

2006-09-08 Thread Kent Johnson
Dick Moores wrote: > Yes, Danny, I've taken yours and Andrei's comment about again() to > heart; I see my confusion. I've revised again() and main(). See my > version 2: http://www.rcblue.com/Python/yen-USD-v2.txt Is this better? Have you noticed the similarity between getRate() and getAmount(

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

2006-09-08 Thread Kent Johnson
Dick Moores wrote: > At 05:37 AM 9/7/2006, Andrei wrote: >> Dick Moores rcblue.com> writes: >> >>> (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) >> Using format strings is easier I think. "%

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

2006-09-08 Thread Dick Moores
Version 3 is now at http://www.rcblue.com/Python/yen-USD-v3.txt . Am I done? Or will a v4 be necessary/advisable? At 05:37 AM 9/7/2006, Andrei wrote: >Dick Moores rcblue.com> writes: > > (1) Have I handled possible user-errors OK? > >I've tested it a bit and it seems to be quite robust. Thanks.

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

2006-09-08 Thread Alan Gauld
> So now that I know better, I'm trying to write the beginnings of a > general setPrecision() function using format strings. However, it > appears that a variable cannot be used instead of the ".2" in > > "%.2f" % 2.234234 The trick is to create the format string using the variable then use th

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

2006-09-08 Thread Justin Ezequiel
Dick Moores rcblue.com> writes: > So now that I know better, I'm trying to write the beginnings of a > general setPrecision() function using format strings. However, it > appears that a variable cannot be used instead of the ".2" in > > "%.2f" % 2.234234 > How to do this? http://www.python.org/

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

2006-09-08 Thread Dick Moores
At 09:39 PM 9/7/2006, Danny Yoo wrote: > >> I'm looking at the last part of the main() function: > >> > >> # > >> def main(): > >> while True: > >> ... > >> again() > >> if again: > >> break > >> # > >> > >> This looks a l

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

2006-09-07 Thread Andrei
Dick Moores rcblue.com> writes: > So now that I know better, I'm trying to write the beginnings of a > general setPrecision() function using format strings. However, it > appears that a variable cannot be used instead of the ".2" in > > "%.2f" % 2.234234 > How to do this? You could use simpl

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

2006-09-07 Thread Andrei
Pawel Kraszewski kraszewscy.net> writes: > > > get me into trouble with the flakiness of float(n)? In testing I > > > didn't find any problems, but .. > > > > Nah. Float accuracy is only a problem if you need around lots of > > significant digits (16 or so). > > I wouldn't bet. Such a simple thi

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

2006-09-07 Thread Danny Yoo
>> I'm looking at the last part of the main() function: >> >> # >> def main(): >> while True: >> ... >> again() >> if again: >> break >> # >> >> This looks a little suspicious. What does the again() function do, and >>

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

2006-09-07 Thread Dick Moores
At 05:37 AM 9/7/2006, Andrei wrote: >Dick Moores rcblue.com> writes: > > > (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) > >Using format strings is easier I think. "%.2f" % 2.34234 will give

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

2006-09-07 Thread Dick Moores
At 07:16 AM 9/7/2006, Danny Yoo wrote: >Hi Dick, > >I'm looking at the last part of the main() function: > ># >def main(): > while True: > ... > again() > if again: > break ># > >This looks a little suspicious. What does

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

2006-09-07 Thread Pawel Kraszewski
Dnia czwartek, 7 września 2006 14:37, Andrei napisał: > > get me into trouble with the flakiness of float(n)? In testing I > > didn't find any problems, but .. > > Nah. Float accuracy is only a problem if you need around lots of > significant digits (16 or so). I wouldn't bet. Such a simple thing

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

2006-09-07 Thread Danny Yoo
Hi Dick, I'm looking at the last part of the main() function: # def main(): while True: ... again() if again: break # This looks a little suspicious. What does the again() function do, and is it supposed to return a v

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

2006-09-07 Thread Andrei
Dick Moores rcblue.com> writes: > (1) Have I handled possible user-errors OK? I've tested it a bit and it seems to be quite robust. > (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) Using forma

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

2006-09-07 Thread Luke Paireepinart
On 9/7/06, Dick Moores <[EMAIL PROTECTED]> wrote: I've just finished a script for converting Yen to USD, andvice-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 tobuild in some bells and whistles. In doing so, some questi

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

2006-09-07 Thread Dick Moores
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 l