instance creatiion as an "event"
Steven Taschuk
staschuk at telusplanet.net
Fri Apr 11 23:20:12 EDT 2003
Quoth Simon Burton:
> On Fri, 11 Apr 2003 17:15:32 -0400, Arthur wrote:
[...]
> > The only thing I seem to be missing is some kind of "hook" to trigger a
> > general update cycle of all existing class instances upon the creation
> > of a new class instance at the interactive prompt
>
> class Member:
> members = []
> def __init__(self):
> for m in Member.members:
> m.notify(self)
> Member.members.append(self)
> def notify(self,other):
> print self,"a new member:",other
Though you will probably want to use weak references in
Member.members, unless you intend that all instances of the class
live as long as the class does.
--
Steven Taschuk staschuk at telusplanet.net
"I may be wrong but I'm positive." -- _Friday_, Robert A. Heinlein
More information about the Python-list
mailing list