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): msgboard- IntegerDivision() return a // b #? return i? else: msgboard- FloatDivision() return a / b #? return f?
If it works, I can write some implementations of msgboard and discuss its scope. It sounded at one point like you were augmenting control flow, but you cleared that up by saying, raise SoftException is not a true raise. Correct? There is a limit to how many behaviors you can fit in a single statement in any language. What behaviors is determined by other choices in the language design. Those choices have many consequences, some linguistic, some social, and some personal. If a dictator always makes impersonal decisions, which linguistic + social ones should he make? If the answer is, "No, we will not strike note J and K because we elected to strike notes L and M instead", then it's disappointing, but it might ease that to know what L and M are. Lastly, that notation I wrote was kind of sly. I might favor msgboard( ZeroNumerator() ) or even msgboard.add( ZeroNumerator() ). How far are you willing to come from the OP's proposal to get it to work? If they add something half-way there, but you don't get exactly what you want, is that fair? -- http://mail.python.org/mailman/listinfo/python-list