The Voidspace Techie Blog

Gravatar Insanely useful and also the first class decorator I've seen that wasn't evolved from a metaclass. This implies a whole brand of metaclasses that replace the old mixins like UserDict. Also, I must have skipped that Hettinger talk because I'd "seen it" before (clearly I hadn't).

For the recipe itself I'm ambivalent on two points. As written it defaults to overwrite=True, and not False [flipped from your description]. On the one hand this will "fix" broken classes that define conflicting comparison operations. On the other hand those writers are either fools or experts so their methods should stay.

Second the fact that it takes an argument. It isn't much heavier to type but it makes it feel more magic even in the default form. The python community standard is to unify similar functions into one function with arguments, but when the side effects are major I get heretical. I wouldn't mind two decorators, total_ordering and force_total_ordering (for the overwrite case). That said I can no longer see the forest for the trees when it comes to python internals so I'll assume that most people don't see mucking with dunders as radical and just want the one function.


Gravatar I'm ambivalent about having it take an argument as well.

I think False should be the default (I'll amend the recipe) - but I did consider (and am still considering) modifying it to allow it to be called without an argument.


Gravatar I've updated the recipe with your suggestion Jack - there are now 'total_ordering' and 'force_total_ordering' decorators.

I'll update this blog entry to reflect this.


Gravatar Sweet!


Name:

Email:

URL:

Comment:  ? 

 

Commenting by HaloScan