Java 企業(yè)應(yīng)用
          不要溫柔的走入那個(gè)良夜

          decorators i: introduction to python decorators

          '''
          Created on Aug 212013

          @author: hailiang
          '''
          class myDecorator(object):
              
              def __init__(self, f):
                  print 
          "1:inside myDecorator.__init__()"
                  self.f 
          = f  # Prove that function definition has completed
           
              def __call__(self, args
          =None):
                  print 
          "3:inside myDecorator.__call__()"
                  self.f(args)
           
          @myDecorator
          def aFunction(args
          =None):
              print 
          "4:inside aFunction()"
              print args
           
          print 
          "2:Finished decorating aFunction()"
           
          aFunction()
          print 
          "another call"
          aFunction(args
          ="I have value")

          posted on 2013-08-21 17:38 cpegtop 閱讀(498) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 镇康县| 富平县| 师宗县| 德昌县| 灌阳县| 德化县| 蓬溪县| 岐山县| 乐陵市| 习水县| 彭阳县| 长白| 宁武县| 中牟县| 连平县| 文山县| 同德县| 离岛区| 巴塘县| 钟祥市| 大港区| 乐亭县| 洛扎县| 诸城市| 拜城县| 晋宁县| 福鼎市| 平安县| 和硕县| 金乡县| 阿合奇县| 遵义市| 东丽区| 涟水县| 南郑县| 乌拉特前旗| 玛多县| 中超| 新民市| 新建县| 敦化市|