我正在寫一個非常簡單的函數,用於我的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