Adding methods from one class to another, dynamically

Michele Simionato michele.simionato at gmail.com
Tue Feb 2 06:47:36 CET 2010


Wanting the same methods to be attached to different classes often is
a code smell (perhaps it is not your case and then use setattr as
others said). Perhaps you can just leave such methods outside any
class. I would suggest you to use a testing framework not based on
inheritance (i.e. use nose or py.test). Perhaps your problem can be
solved with generative tests.



More information about the Python-list mailing list