Java 企業應用
          不要溫柔的走入那個良夜

          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 閱讀(499) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
           
          主站蜘蛛池模板: 开江县| 垫江县| 洛南县| 杭锦旗| 秦安县| 巢湖市| 通海县| 苏尼特右旗| 丰宁| 固阳县| 乐亭县| 永定县| 明光市| 东平县| 南陵县| 镇沅| 化隆| 佛冈县| 肇东市| 连山| 定西市| 西峡县| 图木舒克市| 威远县| 上栗县| 宣威市| 磐石市| 来凤县| 三穗县| 依安县| 乌鲁木齐县| 开平市| 丹寨县| 沙雅县| 南京市| 营口市| 绥棱县| 凌海市| 兴隆县| 五大连池市| 开封市|