Decorater inside a function? Is there a way?

Ron_Adam radam2 at tampabay.rr.com
Fri Apr 1 14:56:55 EST 2005


On Fri, 01 Apr 2005 13:47:06 -0500, Jeremy Bowers <jerf at jerf.org>
wrote:

>On Fri, 01 Apr 2005 18:30:56 +0000, Ron_Adam wrote:
>> I'm trying to figure out how to test function arguments by adding a
>> decorator.
>
>The rest of your message then goes on to vividly demonstrate why
>decorators make for a poor test technique.

So it's not possible to do.  Ok, thanks.

>Is this an April Fools gag? If so, it's not a very good one as it's quite
>in line with the sort of question I've seen many times before. "I have
>a hammer, how do I use it to inflate my tire?"

Not an April fools gag, I'm just new to decorators and google brings
up lots of discussions from the past on how they may be implemented in
the future, but not much in actually how they work or how to use them.
They don't seem to be documented well at the present, possibly because
the syntax and or function of them isn't completely decided on.  I've
been able to figure out the basic principle from the examples I've
found, but that doesn't mean there isn't more possibilities I haven't
found yet.

>Assuming you're serious, why not use one of the many testing technologies
>actually designed for it, and tap into the associated body of knowledge on
>how to accomplish various tasks? Start with what you're trying to do, then
>work on how to do it. 

I'm trying to understand the use's, limits, and possibilities of
decorators.

It just occurred to me that wrapping the contents of a function vs
wrapping the function it's self, could be useful.  

Ron




More information about the Python-list mailing list