Keeping track of subclasses and instances?

Paul Rubin http
Thu Oct 11 09:21:59 CEST 2007


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> Is there a problem with writing C like this?
> class C(object):
>     def __init__(self):
>         logging.warn('Allocating resource ...')
>         self.__log = logging.warn

> It works for me. Have I missed something?

I thought the OP wanted to the program to notice when subclasses were
created, not just instances of them.  As Andreas Kraemer described,
you can do that with a metaclass.



More information about the Python-list mailing list