我正在写一个非常简单的函数,用于我的Django项目中,只有当应用程序处于调试模式时才显示多个页面。在AS3中,您可以使用该方法的调用或应用方法将方法参数应用于其他方法。让我证明:Python的ActionScript等价于apply()/ call()方法吗?
public function secureCall(...arguments):void {
if (SECURE == true) {
// reference the 'call' method below
call.apply(this, arguments);
} else {
throw new IllegalAccessError();
}
}
public function call(a:String, b:int, ...others):void {
// do something important
}
有没有办法在Python做到这一点?我基本上想要做到以下几点:
from django.views.generic.simple import direct_to_template
def dto_debug(...args):
if myapp.settings.DEBUG:
direct_to_tempate.apply(args)
else:
raise Http404
使用'function(* arguments)'notation – JBernardo