global event listeners
Hunter Peress
hunterp at gmail.com
Wed Nov 17 03:32:35 EST 2004
Josiah Carlson wrote:
> "Hunter Peress" <hunterp at gmail.com> wrote:
> >
> > i suppose i could do this, and have an "if self.__name__ ==
> > what_im_looking_for and type(self) == what_im_also_looking_for"
> >
> > next is how can i make every object in a given runtime inherit from
> > this class
>
> class counter(object):
> counter = 0
> def __init__(self, value):
> self.__value = value
>
> def get_v(self):
> return self.__value
> def set_v(self, val):
> self.__value = val
> counter.counter += 1
> value = property(get_v, set_v)
>
> >>> a = counter(1)
> >>> b = counter(2)
> >>> a.counter
> 0
> >>> b.counter
> 0
> >>> a.value = 0
> >>> a.counter
> 1
> >>> b.counter
> 1
> >>>
>
>
> - Josiah
Well yes, but im looking for a non-1:1 way of making every object be a
child of this new class. i would have to do an insane amount of
regex.... ;-)
More information about the Python-list
mailing list