Quantcast
Channel: User killajoule - Stack Overflow
Viewing all articles
Browse latest Browse all 36

How can I apply a decorator to an imported function? [duplicate]

$
0
0

Suppose I have imported a function:

from random import randint

and then want to apply a decorator to it. Is there some syntactic sugar for this, perhaps something like so?

@decoratorrandint

Or do I have create a wrapper function to decorate, like so?

@decoratordef randintWrapper(*args):    return random.randint(*args)

Viewing all articles
Browse latest Browse all 36

Latest Images

Trending Articles





Latest Images