>>> def deco(func):
...      def kdeco():
...          print("before myfunc() called.")
...          func()
...          print("  after myfunc() called.")
...      return kdeco
...
>>> @deco
... def myfunc():
...      print(" myfunc() called.")
...
>>> myfunc()
before myfunc() called.
 myfunc() called.
  after myfunc() called.
>>> deco(myfunc)()
before myfunc() called.
before myfunc() called.
 myfunc() called.
  after myfunc() called.
  after myfunc() called.
1.
why there are two lines :before myfunc() called.and tow lines :after
myfunc() called. in the output?
2.why the result is not
before myfunc() called.
 myfunc() called.
  after myfunc() called.
before myfunc() called.
 myfunc() called.
  after myfunc() called.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to