I have two classes: Account and Operator. Account contains a list of Operators. Now, whenever an operator (in the list) receives a message I want to notify Account object to perform some business logic as well.
I think of three alternatives on how to achieve this:
1) Hold a reference within Operator to the container [Account] object and call methods directly. Not absolutely good because of circular references.
2) Use events. As far as I know there is no built-in event handling mechanism in Python. So, this one is a bit tricky to implement.
3) Don't send messages to Operators directly. Instead, operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators.
I wonder which approach is the most advantageous from the architectural point of view. How do you usually handle this task?
It would be great if you could point out snippets in Python.