[Tutor] Python Docs (Was: Reformatting phone number)

Dotan Cohen dotancohen at gmail.com
Fri Aug 22 22:23:58 CEST 2008


2008/8/22 Lie Ryan <lie.1296 at gmail.com>:
> You should also be aware of python's introspection abilities. If you
> have an object, you could do help(object), dir(object) to get the help
> file and a dictionary containing the members of the object (if run from
> a script, you might need to add print statement, e.g. print
> dir(object) ).

If I know their names :(

> In the case of "finding" str.startswith (i.e. a class' members), you
> could do this from the interactive prompt:
>
>>>> help(str)
> this will print the documentation of str module (and the documentation
> for all its children too)

Good stuff in there, I will spend some time familiarizing myself with
those functions.

> also, typing:
>>>> help()
> will open _interactive_ help with a prompt

This is great! I had to install some docs as Ubuntu does not install
them by default, but that is no problem.

>>>> help('modules')
> would list all available modules
>
>>>> help('keywords')
> would list all of python's reserved words
>
>>>> help('topics')
> would list some other topics you could pass to help()

I will go through them. Thanks.

> The "online"[1] help is a very powerful tool, use it often. help() and
> dir() can also be used from a script, although you might need to add
> print statement.
>
> [1] online refers to the fact that help() is generated from docstrings
> on-the-fly, it is not related Internet at all. PS: There is also the
> Internet version of the documentation

Thanks.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü


More information about the Tutor mailing list