Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""Decorator.""" 

2 

3 

4class reify(object): 

5 

6 """Put the result of a method which uses this (non-data) 

7 descriptor decorator in the instance dict after the first call, 

8 effectively replacing the decorator with an instance variable.""" 

9 

10 def __init__(self, wrapped): 

11 self.wrapped = wrapped 

12 

13 def __get__(self, inst, objtype=None): 

14 if inst is None: 

15 return self 

16 val = self.wrapped(inst) 

17 setattr(inst, self.wrapped.__name__, val) 

18 return val