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)
| 3780 | |
| 3781 | |
| 3782 | def 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 | |
| 3813 | def _turtle_docrevise(docstr): |
| 3814 | """To reduce docstrings from RawTurtle class for functions |
no outgoing calls
no test coverage detected