Built-in functions:
Reference
Https://docs.python.org/2/library/functions.html
Decorative Device
Adorners are functions, except that the function can have special meanings, adorners are used to decorate functions or classes, and adorners can be used to add actions before and after a function is executed.
# define function, for call, function inside not execute
# function names > generation of reference functions
# @ + function name
function
# 1. Automatically executes the outer function and passes the function name F1 below as a parameter
# 2. The return value of the outer function is repeatedly assigned to F1
Example 1:
#!/usr/bin/env python# author:leon Wang Email: [Email protected]def outer (func): Def inner (*args,**kwargs): pri NT (' before ') R = func (*args,**kwargs) print ("after") return R return inner@outerdef F1 (ARG): PR Int (ARG) return "Comeon" @outerdef F2 (ARG1,ARG2): Print ("F2") ret=f1 ("Getdown") print ("Return value", ret) F2 (22,33)
Example 2:
#!/usr/bin/env python# author: leon wang email: [email protected] "def  F1 (): print (123) Def f2 (a): print (456) F2 (F1) "Def login (func): print ("Nb, passed user verification ...") return funcdef home (name): print ("Welcome [%s] to home page " % name) @logindef  TV (name): print (" welcome [%s ] to tv page " % name) Def movie (name): print (" Welcome [%s] to movie page " % name) #tv = login (TV) TV (" Leon ")" Def login (func): def inner (ARG): print ("NB, passed user verification. func (ARG) return&nBsp;innerdef home (name): print ("Welcome [%s] to home page" % name) @logindef  TV (name): print ("Welcome [%s] to tv page " % name) Def movie (name): print (" Welcome [%s] to movie page " % name) #tv = login (TV) TV (" Leon ")
This article is from the "wind continue to blow" blog, please be sure to keep this source http://fengjixuchui.blog.51cto.com/854545/1786026
Python Day4 function Adorner