Re: Proper way to handle errors in a module

2011-05-12 Thread Ben Finney
Andrew Berg writes: > So that's where that info is. I wasn't looking in the tutorial > section. Does this mean you haven't worked through the tutorial? Time to remedy that. -- \ “You are welcome to visit the cemetery where famous Russian and | `\Soviet composers, artists, and writer

Re: Proper way to handle errors in a module

2011-05-12 Thread Steven D'Aprano
On Thu, 12 May 2011 15:26:27 -0500, Tycho Andersen wrote: > On Thu, May 12, 2011 at 03:12:39PM -0500, Andrew Berg wrote: >> On 2011.05.12 02:25 PM, MRAB wrote: >> > You can raise an exception wherever you like! :-) >> If I raise an exception that isn't a built-in exception, I get >> something like

Re: Proper way to handle errors in a module

2011-05-12 Thread Andrew Berg
On 2011.05.12 03:20 PM, Corey Richardson wrote: > class HelloError(Exception): > pass > > Of course, there are all sorts of other things you could do with your > exception. > > http://docs.python.org/tutorial/errors.html#user-defined-exceptions So that's where that info is. I wasn't looking in

Re: Proper way to handle errors in a module

2011-05-12 Thread Ethan Furman
Andrew Berg wrote: On 2011.05.12 02:25 PM, MRAB wrote: You can raise an exception wherever you like! :-) If I raise an exception that isn't a built-in exception, I get something like "NameError: name 'HelloError' is not defined". I don't know how to define the exception. class HelloError(Exce

Re: Proper way to handle errors in a module

2011-05-12 Thread MRAB
On 12/05/2011 21:12, Andrew Berg wrote: On 2011.05.12 02:25 PM, MRAB wrote: You can raise an exception wherever you like! :-) If I raise an exception that isn't a built-in exception, I get something like "NameError: name 'HelloError' is not defined". I don't know how to define the exception.

Re: Proper way to handle errors in a module

2011-05-12 Thread Tycho Andersen
On Thu, May 12, 2011 at 03:12:39PM -0500, Andrew Berg wrote: > On 2011.05.12 02:25 PM, MRAB wrote: > > You can raise an exception wherever you like! :-) > If I raise an exception that isn't a built-in exception, I get something > like "NameError: name 'HelloError' is not defined". I don't know how

Re: Proper way to handle errors in a module

2011-05-12 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/12/2011 04:12 PM, Andrew Berg wrote: > On 2011.05.12 02:25 PM, MRAB wrote: >> You can raise an exception wherever you like! :-) > If I raise an exception that isn't a built-in exception, I get something > like "NameError: name 'HelloError' is not

Re: Proper way to handle errors in a module

2011-05-12 Thread Andrew Berg
On 2011.05.12 02:25 PM, MRAB wrote: > You can raise an exception wherever you like! :-) If I raise an exception that isn't a built-in exception, I get something like "NameError: name 'HelloError' is not defined". I don't know how to define the exception. -- http://mail.python.org/mailman/listinfo/

Re: Proper way to handle errors in a module

2011-05-12 Thread MRAB
On 12/05/2011 20:14, Andrew Berg wrote: On 2011.05.11 01:05 PM, Roy Smith wrote: You want to raise specific errors. Let's say you've got a function like this: def airspeed(swallow): speeds = {"european": 42, "african", 196} return speeds[swallow] If somebody passes an in

Re: Proper way to handle errors in a module

2011-05-12 Thread Andrew Berg
On 2011.05.11 01:05 PM, Roy Smith wrote: > You want to raise specific errors. Let's say you've got a function like > this: > > def airspeed(swallow): >speeds = {"european": 42, > "african", 196} >return speeds[swallow] > > If somebody passes an invalid string, it will raise K

RE: Proper way to handle errors in a module

2011-05-11 Thread Prasad, Ramit
way to handle errors in a module On 2011.05.11 12:57 PM, Patty wrote: > Hi Andrew - > > Sometimes you want an exception come up and then use that information to > take your > program in some direction. Right, but I'm wondering how I should handle errors in a module, where differ

Re: Proper way to handle errors in a module

2011-05-11 Thread Andrew Berg
On 2011.05.11 12:57 PM, Patty wrote: > Hi Andrew - > > Sometimes you want an exception come up and then use that information to > take your > program in some direction. Right, but I'm wondering how I should handle errors in a module, where different people will want their programs to do different

Re: Proper way to handle errors in a module

2011-05-11 Thread Roy Smith
In article , Andrew Berg wrote: > I'm a bit new to programming outside of shell scripts (and I'm no expert > there), so I was wondering what is considered the best way to handle > errors when writing a module. Do I just let exceptions go and raise > custom exceptions for errors that don't trigge

Re: Proper way to handle errors in a module

2011-05-11 Thread MRAB
On 11/05/2011 18:29, Andrew Berg wrote: I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering what is considered the best way to handle errors when writing a module. Do I just let exceptions go and raise custom exceptions for errors that don't trigger

Re: Proper way to handle errors in a module

2011-05-11 Thread Patty
- Original Message - From: "Andrew Berg" To: Sent: Wednesday, May 11, 2011 10:29 AM Subject: Proper way to handle errors in a module I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering what is considered the best way to handle errors