0

To create a class usable in Python is pretty straight-forward: http://code.activestate.com/recipes/54352-defining-python-class-methods-in-c/

But how to make methods static?

1

1 Answer 1

1

Use the METH_STATIC flag in PyMethodDef. The method will be passed NULL as the first parameter rather than an instance of the type.

static PyMethodDef FooMethods[] = 
{
    {"__init__", Foo_init, METH_VARARGS, 
     "doc string"},
    {"doSomething", Foo_doSomething, METH_VARARGS | METH_STATIC,
     "doc string"},
    {NULL},
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.