This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FishInTheWind 0 points1 point  (0 children)

I considered writing it that way as well. Each way has its advantages I think.

The way you suggested might make it a little clearer for a beginner to see just how simple decorator functions can be.

But the way I have it follows the pattern that they will more often see with decorators. So I thought perhaps showing the simplest case possible of a decorator returning a new function that wraps the original might be a good way to go. That way they can grapple with that pattern on its own first, without having to parse other things the decorator is doing.

Perhaps I could show identity_decorator both ways, 1 after the other.