Adding method to class at run-time: bad style?

Grant Edwards invalid at invalid
Wed Apr 8 09:57:01 EDT 2009


On 2009-04-08, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:

>>>      ClientForm.Control = FancyControl
>>>      ClientForm.CheckboxControl = FancyCheckboxControl
>>
>> That would work -- but there are probably 8 or 10 different
>> Control subclasses. It's a bit tedious mixing them all one at a
>> time, and you need more "inside" information (the names of all
>> the different subclasses).
>
> New style classes have a __subclasses__() method that could be
> used to find all of them (*at a certain moment*) -- but
> considering all the issues, I think that monkey-patching the
> base class is the "less bad" option in this case...

Of course I could just 


-- 
Grant Edwards                   grante             Yow! Th' MIND is the Pizza
                                  at               Palace of th' SOUL
                               visi.com            



More information about the Python-list mailing list