(An Unofficial) Python Tutorial Wiki

putting the community back in "maintained by the community"

44dx

Decorators are too much at this stage IMO. It is important not to overwhelm the reader. The reader hasn't even seen exceptions, classes and modules, which are much more commonly used than decorators. By the way, the docorator example goes on to use 'classmethod' , 'staticmethod' etc, which the reader has probably no clue about.

If we do want decorators in the tutorial, there can be a section later in the tutorial titled "Advanced Function Features", which first shows functions being passed around as other objects, closures and then decorators.

This is a introductory tutorial - it is important to build new concepts on top of existing ones. New terminology should always be defined at the place it is first used. Occasionally it may be okay to break this rule if the new terminology is defined soon after it is used.

Comments

I agree, especially since decorators do so many "advanced" things (rebinding names, taking functions as arguments, dynamically defining inner functions, etc.)

"Advanced Function Features" would also be a good place for generators, instead of "Classes", where they currently inexplicably live.

I agree that the decorators should be moved to a later place, and I also think the example could be simplified (an adding function is a bit too abstract for me); how about a "debugging decorator" instead, which simply prints the arguments and return values for a decorated function?

A "debugging decorator" is definitely more useful. I've always had pretty good success explaining decorators to people with adding functions, which is why I used it as the example.