blob: 5e8f7c8371a608f241321fc0a5770a85ce4c96ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# example1.py
import decorators
def do_nothing(self):
"No magic docstring here"
dec_do_nothing=decorators.decorator(do_nothing)
def identity(x):
"[staticmethod]"
return x
dec_identity=decorators.decorator(identity)
def name(cls):
"[classmethod]"
return cls.__name__
dec_name=decorators.decorator(name)
class OldStyle:
do_nothing=dec_do_nothing
identity=dec_identity
class NewStyle(object):
name=dec_name
o=OldStyle() # creates an old style instance
n=NewStyle() # creates a new style instance
|