Help with function prototype

Chris Rebert clp2 at rebertia.com
Thu Dec 3 15:41:45 EST 2009


On Thu, Dec 3, 2009 at 3:02 AM, Nadav Chernin <Nadav.C at qualisystems.com> wrote:
> Hi, all
>
> In past I asked about module – inspect, that can’t to get me prototype of
> C-implemented functions ( usually all built-in functions ).
>
> But, still I see that all Python Editors ( IDLE for example ) can to show
> prototype of built-in functions – by tooltip. When you print for example:
> sum(, you see what kind of parameters you must to enter.
>
> So, how IDLE know it?

It doesn't really; it only shows the function's docstring, which /just
so happens/ to document the parameters in the particular case of the
built-in functions:

$ python
Python 2.6.2
Type "help", "copyright", "credits" or "license" for more information.
>>> print sum.__doc__
sum(sequence[, start]) -> value

Returns the sum of a sequence of numbers (NOT strings) plus the value
of parameter 'start' (which defaults to 0).  When the sequence is
empty, returns start.
>>> type(sum.__doc__)
<type 'str'>

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list