Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 027de25

Browse files
committed
add module decorator
1 parent b7b81ee commit 027de25

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test_decorator/test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
def decorator1(func):
4+
def wrapper():
5+
print 'hello python 1'
6+
func()
7+
print 'end 1'
8+
return wrapper
9+
10+
def decorator2(func):
11+
def wrapper():
12+
print 'hello python 2'
13+
func()
14+
print 'end 2'
15+
return wrapper
16+
17+
@decorator1
18+
def test():
19+
print 'hello python!'
20+
21+
test()

0 commit comments

Comments
 (0)