Skip to content

Move getmethparlist function from turtle to inspect module #137387

@adorilson

Description

@adorilson

Feature or enhancement

Proposal:

The getmethpartlist turtle module function does work which seems to be supposed to be done by the inspect module.

In fact, getmethpartlist calls inspect.signature and then iterates over it to produce a call to the callable. Perhaps this second part could also be implemented in the inspect module.

In an issue, @terryjreedy said, “For calls that just want the call signature, I wonder if calling getmethodparlist could be replaced by calling signature.”

So, my suggestion is to add two new methods to Signature class, which:

  1. Returns the call:
class Signature():
    def as_call(self) -> string : ...
  1. Returns a new Signature without the first parameter if ob is a method:
class Signature():
    def as_function(self): ...

Then, getmethpartlist could be:

def getmethpartlist(ob):
    defs = inspect.signature(ob).as_function()
    call = defs.as_call()
   return str(defs), call

Thoughts?

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

https://discuss.python.org/t/move-getmethparlist-function-from-turtle-to-inspect-module/97172

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions