MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / getmethparlist

Function getmethparlist

Python/Turtle.py:3782–3811  ·  view source on GitHub ↗

Get strings describing the arguments for the given object Returns a pair of strings representing function parameter lists including parenthesis. The first string is suitable for use in function definition and the second is suitable for use in function call. The "self" parameter is

(ob)

Source from the content-addressed store, hash-verified

3780
3781
3782def getmethparlist(ob):
3783 """Get strings describing the arguments for the given object
3784
3785 Returns a pair of strings representing function parameter lists
3786 including parenthesis. The first string is suitable for use in
3787 function definition and the second is suitable for use in function
3788 call. The "self" parameter is not included.
3789 """
3790 defText = callText = ""
3791 # bit of a hack for methods - turn it into a function
3792 # but we drop the "self" param.
3793 # Try and build one for Python defined functions
3794 args, varargs, varkw = inspect.getargs(ob.__code__)
3795 items2 = args[1:]
3796 realArgs = args[1:]
3797 defaults = ob.__defaults__ or []
3798 defaults = ["=%r" % (value,) for value in defaults]
3799 defaults = [""] * (len(realArgs)-len(defaults)) + defaults
3800 items1 = [arg + dflt for arg, dflt in zip(realArgs, defaults)]
3801 if varargs is not None:
3802 items1.append("*" + varargs)
3803 items2.append("*" + varargs)
3804 if varkw is not None:
3805 items1.append("**" + varkw)
3806 items2.append("**" + varkw)
3807 defText = ", ".join(items1)
3808 defText = "(%s)" % defText
3809 callText = ", ".join(items2)
3810 callText = "(%s)" % callText
3811 return defText, callText
3812
3813def _turtle_docrevise(docstr):
3814 """To reduce docstrings from RawTurtle class for functions

Callers 1

_make_global_funcsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected