MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/578484_Observer_Pattern/recipe-578484.py:4–13  ·  view source on GitHub ↗
(self, excluded)

Source from the content-addressed store, hash-verified

2
3class Subject:
4 def __init__(self, excluded):
5 # excluded is a list of attribute names
6
7 # who should be notified
8 self.__dict__['_observers'] = []
9
10 # which attrs should not trigger a notification
11 # obviously it can be done the other way round if needed
12 # i.e.which attrs trigger a notification
13 self.__dict__['_excluded_attrs'] = copy.copy(excluded)
14
15 def __setattr__(self, attrname, value):
16 # set the attribute

Callers

nothing calls this directly

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected