[Baypiggies] Stylin' in Python..

Chris Clark Chris.Clark at ingres.com
Sat Jan 5 00:17:16 CET 2008

On 1/4/2008 12:40 PM, Glen Jarvis wrote:
> class General: pass
> class Specific1(General): pass
> class Specific2(General): pass
> def raiser0():
>     X = General()           # Raise superclass instance
>     raise X

Quick copy/paste of what I tend to use;

class MyBaseException(Exception):
    """Base exception, probably redundant"""
    def __init__(self, value):
        self.value = value
    def __str__(self):
        #return self.value
        return repr(self.value)

class MyNotImplemented(MyBaseException):
    ## fake so that it is not seen the same as real NotImplemented
class CompareNotAllowed(MyBaseException):

raise CompareNotAllowed("can only compare same types")

More information about the Baypiggies mailing list