Have you ever written a module that looked like this?
subscribers = []
def addSubscriber(subscriber):
subscribers.append(subscriber)
def publish(message):
for subscriber in subscribers:
subscriber.notify(message)
And then used it like this?
from publisher import publish
class worker:
def work(self):
publish(self)
I've
(
Read more... )
Comments 4
(The comment has been removed)
It's Python. Some things are horrible, but everything is testable. For example, consider this little gem:
class Thing ( ... )
Reply
(The comment has been removed)
For example, libraries like JMock achieve similar, if not identical, results by using java.lang.reflect.Proxy and friends.
(And who says bytecode manipulation has to be hard.)
Reply
Leave a comment