MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / getmethparlist

Function getmethparlist

tools/python-3.11.9-amd64/Lib/turtle.py:3901–3930  ·  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" paramet

(ob)

Source from the content-addressed store, hash-verified

3899
3900
3901def getmethparlist(ob):
3902 """Get strings describing the arguments for the given object
3903
3904 Returns a pair of strings representing function parameter lists
3905 including parenthesis. The first string is suitable for use in
3906 function definition and the second is suitable for use in function
3907 call. The "self" parameter is not included.
3908 """
3909 defText = callText = ""
3910 # bit of a hack for methods - turn it into a function
3911 # but we drop the "self" param.
3912 # Try and build one for Python defined functions
3913 args, varargs, varkw = inspect.getargs(ob.__code__)
3914 items2 = args[1:]
3915 realArgs = args[1:]
3916 defaults = ob.__defaults__ or []
3917 defaults = ["=%r" % (value,) for value in defaults]
3918 defaults = [""] * (len(realArgs)-len(defaults)) + defaults
3919 items1 = [arg + dflt for arg, dflt in zip(realArgs, defaults)]
3920 if varargs is not None:
3921 items1.append("*" + varargs)
3922 items2.append("*" + varargs)
3923 if varkw is not None:
3924 items1.append("**" + varkw)
3925 items2.append("**" + varkw)
3926 defText = ", ".join(items1)
3927 defText = "(%s)" % defText
3928 callText = ", ".join(items2)
3929 callText = "(%s)" % callText
3930 return defText, callText
3931
3932def _turtle_docrevise(docstr):
3933 """To reduce docstrings from RawTurtle class for functions

Callers 1

_make_global_funcsFunction · 0.85

Calls 2

appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected