def get_callable_signature_as_string(the_callable):
args, varargs, varkw, defaults = inspect.getargspec(the_callable)<EOL>tmp_args = list(args)<EOL>args_dict = {}<EOL>if defaults:<EOL><INDENT>defaults = list(defaults)<EOL><DEDENT>else:<EOL><INDENT>defaults = []<EOL><DEDENT>while defaults:<EOL><INDENT>args_dict[tmp_args.pop()] = defaults.pop()<EOL><DEDENT>while tmp_args:<EOL><INDENT>args_dict[tmp_args.pop()] = None<EOL><DEDENT>args_list = []<EOL>for arg in args:<EOL><INDENT>if args_dict[arg] is not None:<EOL><INDENT>args_list.append("<STR_LIT>" % (arg, repr(args_dict[arg])))<EOL><DEDENT>else:<EOL><INDENT>args_list.append(arg)<EOL><DEDENT><DEDENT>if varargs:<EOL><INDENT>args_list.append("<STR_LIT>" % varargs)<EOL><DEDENT>if varkw:<EOL><INDENT>args_list.append("<STR_LIT>" % varkw)<EOL><DEDENT>args_string = '<STR_LIT:U+002CU+0020>'.join(args_list)<EOL>return "<STR_LIT>" % (the_callable.__name__, args_string)<EOL>
Return a string representing a callable.

    It is executed as if it would have been declared on the prompt.

    >>> def foo(arg1, arg2, arg3='val1', arg4='val2', *args, **argd):
    ...     pass
    >>> get_callable_signature_as_string(foo)
    def foo(arg1, arg2, arg3='val1', arg4='val2', *args, **argd)

    :param the_callable: the callable to be analyzed.
    :type the_callable: function/callable.
    :return: the signature.