DRY and static attribute for multiple classes.
Marc Aymerich
glicerinu at gmail.com
Tue Feb 1 16:53:35 EST 2011
Hi all,
I want to provide an encapsulated static attribute called _registry
for several classes.
I try to use inheritance in order to make it DRY: all classes inherit
from a BaseClass that implements the _registry encapsulation. But with
inheritance it doesn't work how I want, because a single instance of
the _registry is shared between all of the inherited classes, and I
want to have an independent _registry for every class.
How can I do that without coping all the code in every class?
Many Thanks!!
More information about the Python-list
mailing list