This is more a Python question, but maybe somebody knows a solution.

I want to define some kind of hook on a class E which is called whenever another class inherits from E.

So the moment somebody does

class SomeOtherClass(E):
    ...

I want a hook function to be called with SomeOtherClass as argument, in order to monkey-patch SomeOtherClass. Is this possible?


Note: what I *really* want to do is to fix __cmp__() vs. _cmp_(). Sage has the very annoying convention that Python classes should use __cmp__ but Cython classes should use _cmp_. This means that __richcmp__ needs to pull some crazy hacks to determine whether the class is a Python or Cython class.

The obvious solution is to change __cmp__ to _cmp_ for every Python class inheriting from Element (a lot of effort). The non-efficient solution is to check for __cmp__ every time _cmp_ needs to be called. The optimal solution would be to somehow automatically monkey-patch those classes to define _cmp_ as alias for __cmp__.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to