Re: What c.l.py's opinions about Soft Exception?

2008-03-21 Thread castironpi
On Mar 11, 2:30 pm, Lie [EMAIL PROTECTED] wrote: On Mar 12, 12:00 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Actually, the latter is even less cluttered, misses a raise - if pure number of literals is your metric, that is. You don't just compare by the calling code, you've got to

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Chris
If all you wanted was some grouping of exceptions why not something like... soft_exception_list = [IndexError, TypeError] hard_exception_list = [ZeroDivision] try: do_something() except Exception, e: if e.__class__ in soft_exception_list: handle_soft_exception() elif

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Diez B. Roggisch
Chris schrieb: If all you wanted was some grouping of exceptions why not something like... soft_exception_list = [IndexError, TypeError] hard_exception_list = [ZeroDivision] try: do_something() except Exception, e: if e.__class__ in soft_exception_list:

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Lie
On Mar 11, 2:18 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: The problem with callbacks is that it works only for a small amount of callbacks, it'd be too messy to have twenty different callbacks. And the ultimate problem with callbacks is that we can't determine from the outside whether

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Diez B. Roggisch
If you passed an object that has several methods to call (using tuple or list) and you want to handle several softexceptions and ignore some others, you must still pass an empty methods to the one you want to ignore, cluttering the caller's code by significant degree: def somefunc(a,

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Steven D'Aprano
On Tue, 11 Mar 2008 03:14:54 -0700, Lie wrote: Regarding the number of callbacks: you can as well pass an object that has several methods to call. If you passed an object that has several methods to call (using tuple or list) and you want to handle several softexceptions and ignore some

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Steven D'Aprano
On Mon, 10 Mar 2008 12:14:40 -0700, [EMAIL PROTECTED] wrote: Common Lisp has two ways of raising: functions error and signal. Python's raise is like CL's error: you end up in the debugger if the exception is not handled. Exceptions that are raised by CL's signal don't have to be caught: if

Re: What c.l.py's opinions about Soft Exception?

2008-03-11 Thread Lie
(If there is anything weird that I say, please ignore it since I'm writing this half-sleeping) On Mar 12, 12:00 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: (snip) I totally fail to see where raise Equal(a, b) is less cluttered or not than callback(a, b) Actually, the latter is even

Re: What c.l.py's opinions about Soft Exception?

2008-03-10 Thread Lie
On Mar 10, 12:12 pm, John Nagle [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Sat, 08 Mar 2008 22:24:36 -0800, Kay Schluehr wrote: On 9 Mrz., 06:30, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Is it really so exotic that it requires the demand for more use cases?

Re: What c.l.py's opinions about Soft Exception?

2008-03-10 Thread [EMAIL PROTECTED]
On Mar 9, 2:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Is this soft-exception implemented anywhere, so that one can see what experiences and best practices have evolved around using it? Lie's idea is to separate exceptions in two groups, those that must be handled and those that don't. A

Re: What c.l.py's opinions about Soft Exception?

2008-03-10 Thread Diez B. Roggisch
The problem with callbacks is that it works only for a small amount of callbacks, it'd be too messy to have twenty different callbacks. And the ultimate problem with callbacks is that we can't determine from the outside whether the operation should continue or breaks at the point of the

Re: What c.l.py's opinions about Soft Exception?

2008-03-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: On Mar 9, 2:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Is this soft-exception implemented anywhere, so that one can see what experiences and best practices have evolved around using it? Lie's idea is to separate exceptions in two groups, those that must be

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Steven D'Aprano
On Sat, 08 Mar 2008 22:24:36 -0800, Kay Schluehr wrote: On 9 Mrz., 06:30, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Hard Exceptions: terminate the program unless explicitly silenced Soft Exceptions: pass silently unless explicitly caught In this case, I agree with the

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Lie
On Mar 9, 12:05 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 04:51, Lie [EMAIL PROTECTED] wrote: A more through implementation would start from the raiser inspecting the execution stack and finding whether there are any try block above it, if no try block exist it pass silently and

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Kay Schluehr
On 9 Mrz., 09:30, Lie [EMAIL PROTECTED] wrote: On Mar 9, 12:05 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 04:51, Lie [EMAIL PROTECTED] wrote: A more through implementation would start from the raiser inspecting the execution stack and finding whether there are any try block

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Mel
Lie wrote: [ ... ] Soft Exception What is Soft Exception? Soft Exception is an exception that if is unhandled, pass silently as if nothing happened. For example, if a variable turns into NoneType, it'll raise Soft Exception that it have become NoneException, programmers that wants to handle

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Bryan Olson
Lie wrote: [...] Soft Exception is an exception that if is unhandled, pass silently as if nothing happened. [...] Implementation: Simple implementation might be done by catching all exceptions at the highest level, then filtering which exceptions would be stopped (Soft Exception) and which

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Lie
On Mar 9, 6:57 pm, Bryan Olson [EMAIL PROTECTED] wrote: Lie wrote: [...] Soft Exception is an exception that if is unhandled, pass silently as if nothing happened. [...] Implementation: Simple implementation might be done by catching all exceptions at the highest level, then

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Lie
On Mar 9, 4:31 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 09:30, Lie [EMAIL PROTECTED] wrote: On Mar 9, 12:05 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 04:51, Lie [EMAIL PROTECTED] wrote: A more through implementation would start from the raiser inspecting the

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Steven D'Aprano
On Sun, 09 Mar 2008 00:30:51 -0800, Lie wrote: (3) Informing codes above it about what's currently happening inside, the thing is just a mundane report that might be useful to codes above Which might be a useful place to use SoftExceptions Okay, now we're getting somewhere. So, I have a

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Diez B. Roggisch
Lie schrieb: I'm asking about people in c.l.py's opinion about a _probably_ very Pythonic way of doing something if such features is implemented. It is to be known that I'm not a Python expert and actually relatively new to Python programming, so probably I'm just not thinking pythonic enough

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Kay Schluehr
On 9 Mrz., 13:50, Lie [EMAIL PROTECTED] wrote: On Mar 9, 4:31 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 09:30, Lie [EMAIL PROTECTED] wrote: On Mar 9, 12:05 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 9 Mrz., 04:51, Lie [EMAIL PROTECTED] wrote: A more through

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Lie
On Mar 9, 7:54 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 09 Mar 2008 00:30:51 -0800, Lie wrote: (3) Informing codes above it about what's currently happening inside, the thing is just a mundane report that might be useful to codes above Which might be a useful

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Lie
On Mar 9, 9:29 pm, Kay Schluehr [EMAIL PROTECTED] wrote: (snip) You are an appropriate person to consider the workflow in a dynamic language, no matter how the language is implemented internally. I agree, but the only thing I'm not confident to talk about is how it'll be implemented, since I

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread castironpi
D'Aprano suggested callbacks. How does this work for you? class SomeNumeric(object): def __div__(a, b): if b == 0: raise ZeroDivisionError ## Hard Exception... if a == 0: msgboard- ZeroNumerator() f = a / b i = a // b if f == float(i):

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread Diez B. Roggisch
Perhaps similar technique the compiler uses to determine whether a function is a normal function or a generator function? Positive forward lookup for any soft exceptions, which would then activate matching soft exceptions inside the code? The difference between generators and functions is

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread castironpi
On Mar 9, 4:51 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Perhaps similar technique the compiler uses to determine whether a function is a normal function or a generator function? Positive forward lookup for any soft exceptions, which would then activate matching soft exceptions inside

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread John Nagle
Steven D'Aprano wrote: On Sat, 08 Mar 2008 22:24:36 -0800, Kay Schluehr wrote: On 9 Mrz., 06:30, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Is it really so exotic that it requires the demand for more use cases? Are the existing solutions really so incomplete that we

What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Lie
I'm asking about people in c.l.py's opinion about a _probably_ very Pythonic way of doing something if such features is implemented. It is to be known that I'm not a Python expert and actually relatively new to Python programming, so probably I'm just not thinking pythonic enough yet or this

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Kay Schluehr
On 9 Mrz., 04:51, Lie [EMAIL PROTECTED] wrote: A more through implementation would start from the raiser inspecting the execution stack and finding whether there are any try block above it, if no try block exist it pass silently and if one exist it will check whether it have a matching except

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 19:51:24 -0800, Lie wrote: Soft Exception What is Soft Exception? Soft Exception is an exception that if is unhandled, pass silently as if nothing happened. For example, if a variable turns into NoneType, it'll raise Soft Exception that it have become NoneException,

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Kay Schluehr
On 9 Mrz., 06:30, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Hard Exceptions: terminate the program unless explicitly silenced Soft Exceptions: pass silently unless explicitly caught In this case, I agree with the Zen of Python (import this): Errors should never pass