Decorater inside a function? Is there a way?

Ron_Adam radam2 at tampabay.rr.com
Fri Apr 1 13:30:56 EST 2005


I'm trying to figure out how to test function arguments by adding a
decorator.

    @decorate
    def func( x):
        # do something
    return x

This allows me to wrap and replace the arguments with my own, but not
get the arguments that the original function received.

To do that I would need to put the decorator inside the function.

    def func( x):
        @decorate
		# doc something
	return x

Then I could use @decorators to check the function input for
condition, ranges, and or types.

Is there a equivalent way to do that?

Also can I use @decorate with assert?


Ron




More information about the Python-list mailing list