[Python-Dev] METH_CLASS (original) (raw)
Fred L. Drake, Jr. fdrake@acm.org
Thu, 25 Apr 2002 10:20:04 -0400
- Previous message: [Python-Dev] METH_CLASS
- Next message: [Python-Dev] METH_CLASS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thomas Heller writes:
Is the documentation wrong, or is the code wrong (I didn't find any use of METH_CLASS in the CVS sources)?
There's an example in sandbox/datetime/datetime.c; search for "datetime_now".
[I must say that I'm not really sure how this relates to the calling convention flags. Have tried METH_O and METH_VARARGS so far.]
Guido van Rossum writes:
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'll note that while this is a little tedious, it's easily packaged into a helper function.
-Fred
-- Fred L. Drake, Jr. PythonLabs at Zope Corporation
- Previous message: [Python-Dev] METH_CLASS
- Next message: [Python-Dev] METH_CLASS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]