python:practice decorator closure function

instances:

    def    func():

          x=10

        def inner():

            print(x)

       return inner

a=func()

a()  result of execute is  10

print(a())  result of execute is none :because the result is func() result no set return value so return None

closure operation:

in a inner function  ,call enclosing function variable (not global variable),so inner fuction title term as closure operation.

 closure operation can separate itself from that  function environment

about closure operation:

closure operation =function module +the environment of define function.

def    func():

         print('good   ')

    

原文地址:https://www.cnblogs.com/alansuny/p/12497335.html