Fire event when variable is Set/Get

Mike C. Fletcher mcfletch at
Mon Jul 25 06:22:46 CEST 2005

Varghjärta wrote:

>But there is something that keeps bugging me, and that keeps me from
>embracing Python even more as a serious alternative to C#(for me). In
>C# I make heavy use of Get & Set, mainly to fire an event that some
>property has changed so that one can act on that _if one would need
>to. I've grown very used to doing it and it feels like the best way to
>make very OO and reusuable and easy to use Classes.
It's fairly straightforward to implement observability for any of the 
various "modeling" descriptor systems out there.  Attached you'll find a 
quick demo of how one could use BasicProperty with PyDispatcher to 
produce the effect.  The biggest problem is that normally the particular 
events you want to fire are application specific.  Heck, it's a toss-up 
whether the property or the client should be the sender of a message 
(basically depends on whether you normally want to filter by one or the 

The OpenGLContext vrml scenegraph has PyDispatcher-sending fields 
built-in if you want to see a real-world use.  (We have others which use 
BasicProperty + PyDispatcher, but they're not Open-Source).

Have fun,

  Mike C. Fletcher
  Designer, VR Plumber, Coder

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
URL: <>

More information about the Python-list mailing list