0

可以说我下面的代码:

def myDecorator(func):
  def wrapper(self):
    try:
      func(self)
    except Exception as e:
      print "The argument of the function was:" # print "Some Text"
      raise
  wrapper.__name__ = funct.__name__
  return wrapper


@myDecorator
def do_something(self):
  do_something_again("Some text")

我的问题是:如何在我的“except”块中显示赋予函数“do_something_again”的参数?

4

1 回答 1

0

打印str(e)以获取更多信息。你的例子:

def myDecorator(func):
  def wrapper(self):
    try:
      func(self)
    except Exception as e:
      print "The argument of the function was:", str(e)
      raise
  wrapper.__name__ = funct.__name__
  return wrapper
于 2013-03-06T15:13:56.297 回答