Alex G <[EMAIL PROTECTED]> wrote:
> class classA(object):
> @decorator('argument')
> def some_method(self):
> print "An exception should be raised when I'm called, but not
> when I'm defined"
>
> Will result in an exception on definition.
Well, yes it would. That's because what y
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
Alex G <[EMAIL PROTECTED]> wrote:
> 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
>
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
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