[Python] How to have Pybind11 positional-argument names show up on help()?

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    double foo(int x, int y, double dx, double dy) {...};

    PYBIND11_MODULE(mymodule, m) {
    m.doc() = "Module docstring";
    m.def("foo", &foo, "Function docstring");
    }


    Once installed, the help pages don't include the positional argument name and instead replaced with arg<#>:

    >>> from mymodule import foo
    >>> help(foo)

    Help on built-in function foo in module mymodule:

    foo(...) method of builtins.PyCapsule instance
    foo(arg0: int, arg1: int, arg2: float, arg3: float) -> float

    Function docstring

    Continue reading...

Compartilhe esta Página