Alan Isaac <[EMAIL PROTECTED]> writes:
> OK, thanks.
>
> Another approach is to begin with a set of stocks
>
> and remove them as they report. You can then trigger
>
> a report with the empty set instead of repeatedly
>
> calling ``all``. After a report the set can be
>
> "refilled".
Ah, and I
Alan Isaac <[EMAIL PROTECTED]> writes:
> Here is one way:
>
> - for each fund, create a ``reportreceived`` dict that maps stocks to
> booleans (initially False)
> - as each stock notifies its funds, the fund changes False to True and checks
> ``all(reportreceived.values())`` to determine whethe
J. Cliff Dyer wrote:
looks like a good approach to me
OK, thanks.
Another approach is to begin with a set of stocks
and remove them as they report. You can then trigger
a report with the empty set instead of repeatedly
calling ``all``. After a report the set can be
"refilled".
Cheer
That looks like a good approach to me. Alternative to a dict would just
be a count of reported stocks tested against the total number of stocks,
but if one stock reports twice before another reports at all, you'll get
funny results. Your method is probably better, in the general case.
Cheers,
Cl
A question related to the observer pattern...
Suppose I have a variant: there are stocks, mutual funds, and investors. Let us say that funds are observers for multiple stocks, and investors are observers for funds. Once a "month" all stocks notify their observing funds of their end-of-month pri