From: "Guido van Rossum" firstname.lastname@example.org
The devel-docs tell me about METH_CLASS:
- Since this is marked new in 2.3: Is it planned to backport
this stuff into the 2.2.x series? Requiring Python 2.3 for my stuff seems a but harsh currently...
I don't plan to backport this to 2.2 unless there's an overwhelming demand.
What do you accept as overwhelming? The only person I could think of currently beside me is David Abrahams, but maybe I'm wrong ;-)
You have to call classmethod() from C; it's available as &PyClassMethod_Type, you can call it with e.g. PyObject_Call. The argument should be a function object that you created by calling PyCFunction_New. Then stick it into your type's tp_dict (after calling PyType_Ready()).
I know that's complicated; that's why we added METH_CLASS. :-) I'd recommend against trying this unless you absolutely need it.
I need it, so I asked :-) But I'm fine with your recipe (in these cases where I don't have a custom metaclass).