this article illustrates how Python implements multiple decorators for a function. Share to you for your reference, as follows:

the following example shows the application of a number of decorative for a function, can add a breakpoint in the debug mode, running track viewer...

 /usr/bin/env Python #coding:utf-8 def decorator1 #! (func): def (wrapper): print'Hello Python func 'before (return) wrapper def decorator2 (func): def (wrapper): func (print) after'Hello Python return' wrapper @decorator2 def test (@ decorator1): print'Hello (test 'Python! 


operation results:

 Hello Python Hello Python before Hello Python 

! Python on adorners more, the reference to the

1. Python decorator learning (nine step entry)


2. Python decorator and aspect oriented programming

more about the Python related content can be subject to view the station: "Python data structure and algorithm "," Python Socket ", summarizes the programming skills of" Python ", summarizes the skills in the use of function" Python "string manipulation skills summary and" Python and "advanced introductory tutorial classic

hope in this paper, the Python program designed to help all of you.

This paper fixed link: | Script Home | +Copy Link

Article reprint please specify:Python implementation of an example of the application of multiple decorators to a function | Script Home

You may also be interested in these articles!