Personal learning python for a long time, but has always been here to pick a point where to learn, a little overwhelmed. Recently I want to see how the adorner used, and then studied the next.
Simple point of:
#!/usr/bin/python
def say (key): # Create a small function
print ' Your first love! '
Return key
@say
Def hold ():
print ' This is sercod world! '
Hold ()
A brief talk is @say
The Def hold () is a say wrap, the order of execution is say ("#参数就是 #hold function Overall #"), the simple is to put a function of the outer layer of a say function. But the final execution is hold, so the coat function say must point to hold, so the return value returns key----Here the key is the hold itself.
It's a bit of a mouthful, but it's good to understand. If you don't understand, there's no way.
This article is from the "Pang" blog, make sure to keep this source http://pangfei.blog.51cto.com/8832397/1731401
Python @ Decorator Simple to understand