function problem

contro opinion contropinion at gmail.com
Mon Jan 9 22:35:41 EST 2012


code1:

def FirstDeco(func):
   print 'haha'
   y=func()
   return y
   print  y


@FirstDeco
def test():
  print 'asdf'
  return  7

result :
haha
asdf

code2:

def FirstDeco(func):
   print 'haha'
   y=func()
   #return y
   print  y


@FirstDeco
def test():
  print 'asdf'
  return  7

result :
haha
asdf
7

why the result of code1 and code2  is different?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120110/3586b5bb/attachment.html>


More information about the Python-list mailing list