Skip to content

Commit ff1e25b

Browse files
author
lev epshtein
committed
another commit
1 parent a226251 commit ff1e25b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

decorators/syntax.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This is not a valid Python module - Don't run it.
2+
3+
# ONE DECORATOR
4+
def func(arg1, arg2, ...):
5+
pass
6+
7+
func = decorator(func)
8+
9+
# is equivalent to the following:
10+
11+
@decorator
12+
def func(arg1, arg2, ...):
13+
pass
14+
15+
16+
# TWO DECORATORS
17+
def func(arg1, arg2, ...):
18+
pass
19+
20+
func = deco1(deco2(func))
21+
22+
# is equivalent to the following:
23+
24+
@deco1
25+
@deco2
26+
def func(arg1, arg2, ...):
27+
pass
28+
29+
# DECORATOR WITH ARGUMENTS
30+
def func(arg1, arg2, ...):
31+
pass
32+
33+
func = decoarg(arg_a, arg_b)(func)
34+
35+
# is equivalent to the following:
36+
37+
@decoarg(arg_a, arg_b)
38+
def func(arg1, arg2, ...):
39+
pass

0 commit comments

Comments
 (0)