Where is the help function defined?

Trent Mick trentm at activestate.com
Tue Jun 22 18:59:04 EDT 2010


On 10-06-21 10:57 AM, Emile van Sebille wrote:
> On 6/21/2010 10:17 AM Peng Yu said...
>> help(help) gives me the following explanation.
>
> <snip>
>
>> I then looked at pydoc site. But I don't see an entry on help(). How
>> to figure out where help() (or a function in general) is defined?
>
> ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
> Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> dir(help)
> ['__call__', '__class__', '__delattr__', '__dict__', '__doc__',
> '__getattribute__', '__hash__', '__init__', '__module__', '__new__',
> '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
> '__weakref__']
>  >>> help.__module__
> 'site'
>  >>> import site
>  >>> dir (site)
> ['_Helper', '_Printer', '__builtin__', '__builtins__', '__doc__',
> '__file__', '__name__', '_init_pathinfo', '_test', 'abs__file__',
> 'addbuilddir', 'addpackage', 'addsitedir', 'addsitepackages',
> 'aliasmbcs', 'execsitecustomize', 'main', 'makepath', 'os', 'removedup
> paths', 'setBEGINLIBPATH', 'setcopyright', 'setencoding', 'sethelper',
> 'setquit', 'sys']
>  >>> site.__file__
> 'C:\\Python24\\lib\\site.pyc'
>  >>>

"site.py" (at least in the Python trunk) has this:


def sethelper():
     __builtin__.help = _Helper()



Trent

-- 
Trent Mick
http://www.activestate.com



More information about the Python-list mailing list