How to access a function's formal signature?
Carl Banks
pavlovevidence at gmail.com
Tue Aug 11 19:47:38 EDT 2009
On Aug 11, 2:30 pm, kj <no.em... at please.post> wrote:
> In the standard Python interactive interpreter, the string printed
> by the help command when applied to a function includes the function's
> formal signature. E.g.:
>
> >>> def foo(bar, *baz, **frobozz):
>
> ... pass
> ...>>> help(foo)
>
> Help on function foo in module __main__:
>
> foo(bar, *baz, **frobozz)
>
> Here by "signature" I'm referring to the substring "bar, *baz,
> **frobozz" shown above (or, equivalently, any other object from
> which this string could be deduced). (I figured out that I can
> retrieve this signature using methods in the inspect module.)
>
> OK, now, is there a way to modify a function so that pydoc (and
> presumably also the interactive interpreter's help function, etc.)
> will print out a desired specific signature for this function?
I think you'd have to modify pydoc. pydoc pulls this information out
from the function's attributes (and maybe also it's underlying code
object) which are read-only.
Carl Banks
More information about the Python-list
mailing list