The role of python @

In the Python function occasionally see the line of the function definition has modified @functionName, and when the interpreter read such modifiers @, and will first parse the contents of the @, @ function directly put the next line or @ class as a parameter back, and then returns the modified value is assigned to the next row of function objects.
For example:
@a
@b
DEF C ():
...
Python will bottom in the order of the respective function result as input to the next function (function above), that is, a (b (c ()) )

def Funai (a) 
    print 'Funai' 

def funB (b) 
    print 'funB' 

@funA 
@funB 
def func (): 
    print "FUNC"

The result is

funB 
Want

  

Guess you like

Origin www.cnblogs.com/hupingzhi/p/11210401.html