Total Complexity | 5 |
Total Lines | 19 |
Duplicated Lines | 0 % |
1 | """ |
||
10 | try: |
||
11 | return sentinel._cache[name, doc] # memoized |
||
12 | except KeyError: |
||
13 | pass |
||
14 | |||
15 | @object.__new__ # bind a single instance to the name 'Sentinel' |
||
16 | class Sentinel(object): |
||
17 | __doc__ = doc |
||
18 | __slots__ = ('__weakref__',) |
||
19 | __name__ = name |
||
20 | |||
21 | def __new__(cls): |
||
22 | raise TypeError("Can't construct new instances of %r" % name) |
||
23 | |||
24 | def __repr__(self): |
||
25 | return 'sentinel(%r)' % name |
||
26 | |||
27 | def __reduce__(self): |
||
28 | return sentinel, (name, doc) |
||
29 | |||
47 |