Functions that raise exceptions.

2008-06-25 Thread Alex G
Does anyone know how I would go about conditionally raising an exception in a decorator (or any returned function for that matter)? For example: def decorator(arg): def raise_exception(fn): raise Exception return raise_exception class some_class(object): @raise_exception d

Re: Functions that raise exceptions.

2008-06-25 Thread Alex G
whoops! The code should be: def decorator(arg):     def raise_exception(fn):       raise Exception   return raise_exception class some_class(object):     @decorator('meaningless string')     def some_method(self):         print "An exception should be raised when I'm called, but not when I'm

Re: Functions that raise exceptions.

2008-06-25 Thread Alex G
I'm sorry about the typos, but that doesn't seem to be what the issue is (I typed it into the textbox rather carelessly, I apologize :-( ). It seems to be an issue with passing the decorator an argument: Given: def decorator(arg): def raise_exception(fn): raise Exception return ra