Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Mac Ryan
On Wed, 28 Sep 2011 10:15:07 -0400 "Prasad, Ramit" wrote: > >If you are using asserts for data validation, then your code is > >broken. The caller can disable every single assert, and hence remove > >your data validation, by simply passing a command line switch when > >calling your program. >

Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Prasad, Ramit
>If you are using asserts for data validation, then your code is broken. >The caller can disable every single assert, and hence remove your data >validation, by simply passing a command line switch when calling your >program. To be fair, there are plenty of situations where someone has enough c

Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Steven D'Aprano
Mac Ryan wrote: I have to say - however - that even after a few years of python development I seldom use exceptions that way: in fact I can only remember having subclassed error classes once, when I wrote a library that was intended to be used by third-parties (for the exact same reasons that yo

Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Alan Gauld
On 28/09/11 10:23, Mac Ryan wrote: I have to say - however - that even after a few years of python development I seldom use exceptions that way: in fact I can only remember having subclassed error classes once, when I wrote a library that was intended to be used by third-parties (for the exact s

Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Mac Ryan
On Wed, 28 Sep 2011 09:03:11 +0100 Alan Gauld wrote: > Remember that when handling exceptions we should be trying > to recover the situation not just bombing with an error message. > Exceptions should not be thought of as purely about > messages, they are opportunities to recover the situation w

Re: [Tutor] map one file and print it out following the sequence

2011-09-28 Thread Alan Gauld
On 28/09/11 04:34, lina wrote: File 1 is: 3 C 1 CUR C19 10.200 12.0110 4 CR1 1 CUR C20 1 -0.060 12.0110 5HC 1 CUR H20 10.060 1.0080 File 2 is: ATOM 2 H20 CUR 1 30.338 28.778 -6.812 1.

Re: [Tutor] Why subclassing exceptions?

2011-09-28 Thread Alan Gauld
On 28/09/11 07:33, Mac Ryan wrote: raise BaseException('Something is wrong here!') Never raise BaseException directly! **I would like to know more on the rationale behind this guidelines, though.** raise StandardError('This value should be True.') does the job in a much more elegant

Re: [Tutor] raw_input() slice list

2011-09-28 Thread questions anon
Excellent, thank you and yes I need to work on how to catch and handle exceptions Thanks again! On Wed, Sep 28, 2011 at 4:13 PM, bob gailer wrote: > On 9/27/2011 11:18 PM, questions anon wrote: > > I would like to use user_input() to decide how to slice a list. > This works fine until I try to