Re: [Tutor] please return flys in ointment

2013-07-09 Thread Steven D'Aprano
On 10/07/13 04:05, Jim Mooney wrote: On 8 July 2013 18:16, Steven D'Aprano wrote: I wouldn't even call it an Error, since it's actually a limitation of Jim's code, not an actual error. Good point. But since I'm using try-except on input anyway, largely for int-checking, i figured why not use

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Steven D'Aprano
On 09/07/13 05:59, Jim Mooney wrote: To make a custom error, first pick another error that's a superset of what you're doing. Then simply derive your error class from it. As a minimum: class TooHugeError (ValueError): pass Actually, I didn't get to classes yet since I wanted to nail proc

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Steven D'Aprano
On 09/07/13 05:47, Dave Angel wrote: On 07/08/2013 01:57 PM, Jim Mooney wrote: On 8 July 2013 00:12, Steven D'Apranocatching ArithmeticError further on), please use a custom exception Well, an Arithmetic Error was better than bubbling up to a totally general one. I'm not sure how do custom

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Jim Mooney
> To make a custom error, first pick another error that's a superset of what > you're doing. Then simply derive your error class from it. As a minimum: > > class TooHugeError (ValueError): > pass > > Actually, I didn't get to classes yet since I wanted to nail procedural - I'm in no rush - bu

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Dave Angel
On 07/08/2013 01:57 PM, Jim Mooney wrote: On 8 July 2013 00:12, Steven D'Apranocatching ArithmeticError further on), please use a custom exception Well, an Arithmetic Error was better than bubbling up to a totally general one. I'm not sure how do custom error code. Short example, please ;')

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Jim Mooney
On 8 July 2013 00:12, Steven D'Apranocatching ArithmeticError > further on), please use a custom exception > Well, an Arithmetic Error was better than bubbling up to a totally general one. I'm not sure how do custom error code. Short example, please ;') Jim __

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Steven D'Aprano
Comments on your code inline below. On Sat, Jul 06, 2013 at 02:38:27PM -0700, Jim Mooney wrote: > import sys > > # Data > ones = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', > '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'} > > tens = {'2': 'twenty', '3': 'thirty', '4'

Re: [Tutor] please return flys in ointment

2013-07-07 Thread Alan Gauld
On 07/07/13 08:44, Jim Mooney wrote: thought about it, but it seemed to me that when most people are verbalizing big numbers, they tend not to use 'and.' True in the USA but not the UK (and derivatives?). Here most folks seem to put the 'and' in. eg: three thousand, four hundred and fifty six

Re: [Tutor] please return flys in ointment

2013-07-07 Thread Dave Angel
On 07/07/2013 02:47 AM, Jim Mooney wrote: On 6 July 2013 22:52, Dave Angel wrote: The other author does not use hyphens or commas in the words. He ends each string with a blank. And he neglected to handle zero. He also is buggy beyond a nonillion-1. I found yet another implementation t

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/07/2013 01:30 AM, Dave Angel wrote: On 07/06/2013 10:40 PM, Jim Mooney wrote: On 6 July 2013 19:09, Dave Angel wrote: If you'd like, I'll post my full version, changed as little as possible from That would be helpful. The corrections are already four times the size of

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 10:40 PM, Jim Mooney wrote: On 6 July 2013 19:09, Dave Angel wrote: If you'd like, I'll post my full version, changed as little as possible from That would be helpful. The corrections are already four times the size of the program, and at least three pots of cof

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 09:18 PM, Jim Mooney wrote: On 6 July 2013 18:01, ALAN GAULD wrote: If its structured use a parser for preference. (HTML, XML or pyparser etc for proprietary type stuff Ah, I see - don't bother with a parser unless you have a lot of structure. BTW, I extracted the main funct

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Steven D'Aprano
On 07/07/13 07:38, Jim Mooney wrote: I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that. But naturally, lest I look dumb, I'd appreciate criticism,

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Jim Mooney
On 6 July 2013 18:01, ALAN GAULD wrote: > > > If its structured use a parser for preference. (HTML, XML or pyparser etc > for > proprietary type stuff > Ah, I see - don't bother with a parser unless you have a lot of structure. BTW, I extracted the main function from my program to a test program

Re: [Tutor] please return flys in ointment

2013-07-06 Thread ALAN GAULD
>Oddly, I was just looking at pyparsing, and it mentioned it's good for Python >2.3  >and above. But that left me thinking "Do they mean version 3 and above?"  >since a lot is not ready for version 3. Since we know a lot has changed since >2.3 and especially since 2.3 I'd take it with  a pinch o

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Jim Mooney
On 6 July 2013 16:06, Alan Gauld wrote: Probably better to take a chance and say Python versions above 2.7. > Backward compatibility is pretty good in Python land. Oddly, I was just looking at pyparsing, and it mentioned it's good for Python 2.3 and above. But that left me thinking "Do they mea

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Jim Mooney
On 6 July 2013 15:34, Dave Angel wrote: General comments: etc,,, Thanks very much. Very detailed. I'll print that out and make changes ;') I was worried about linewrap. I'll have to cut my big margins down and pay more attention to it. As a start, where I print Zero and exit, it seemed natural s

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 06:34 PM, Dave Angel wrote: On 07/06/2013 05:38 PM, Jim Mooney wrote: I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that. But natura

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Alan Gauld
On 06/07/13 22:38, Jim Mooney wrote: naturally, lest I look dumb, I'd appreciate criticism, OK, here are a few comments, take em or leave em... import sys # Data # Functions def make_triplets_from_input(): Why not pass in the prompt string as an argument? '''Enter a positive i

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 05:38 PM, Jim Mooney wrote: I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that. But naturally, lest I look dumb, I'd appreciate criti

[Tutor] please return flys in ointment

2013-07-06 Thread Jim Mooney
I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that. But naturally, lest I look dumb, I'd appreciate criticism, improvements of bad form, or if anyone