---
title: "Python decorator"
author: "aaron_ch"
date: "2011-11-03T22:31:07Z"
tags: []
categories: ["编程语言"]
slug: "python-decorator"
draft: false
lastmod: "2011-11-03T22:31:07Z"
id: 1233844
url: "https://aaron-ch.iteye.com/blog/1233844"
---

#decorator
def before(func):
    def wapper(*args):
        print "print before invoke foo function"
        func(*args)
        print "print after invoke foo function"
    return wapper

@before
def foo(x):
    print "this is dummy function" + x


foo("mm")