watching mutables?

Jiba jiba at tuxfamily.org
Sat Sep 28 16:24:31 EDT 2002


Anton Vredegoor wrote:

> Hello all,
> 
> here's a function I would like to have:
> 
> <hypothetical code>
> 
>>>> m = [1,2]
>>>> m
>>>> [1,2]
>>>> from watcher import watch
>>>> watch(m)
>>>> m.append(3)
>>>> "hey, you changed variable m!, new value is [1,2,3]"
> 
> </hypothetical code>
> 
> Is this possible? How would this be called?
> 
> Anton.

Try EditObj (http://oomadness.tuxfamily.org/en/editobj) and look at the 
module editobj.eventobj.

It does exactely what you need, but it is quite a hack...

Jiba



More information about the Python-list mailing list