Decorated class question

Ian Kelly ian.g.kelly at gmail.com
Mon Jan 16 11:30:53 EST 2012


On Mon, Jan 16, 2012 at 8:10 AM, deathweaselx86 <deathweasel at gmail.com> wrote:
> Pardon me if this is a silly question.
>
> If I decorate a class, then subclass it, does my subclass feature
> whatever the decorator did to my superclass?

That depends on what the decorator did.  Changes made directly to the
class itself, such as items added to the class dict, will be
inherited.  Other operations performed, such as registering the class
with a framework of some sort, are not inherited and would need the
decorator to be applied to the subclass as well.

Cheers,
Ian



More information about the Python-list mailing list