naive doc question

Discussion in 'Python' started by Gabriel B., Jan 30, 2005.

  1. Gabriel B.

    Gabriel B. Guest

    Is it just me that can't find a full reference in the docs?

    I wanted a list of all the methods of dict for example... where can i find it?

    Thanks, and sorry if this question is just dumb, i really can't find it
    Gabriel B., Jan 30, 2005
    #1
    1. Advertising

  2. I wouldn't call the responses here helpful; they seem overspecific. I
    had a similar problem which led to the follwing code. After I came up
    with this I saw a very similar utility was derived in Dive into Python.


    see
    http://diveintopython.org/power_of_introspection/index.html#apihelper.divein

    Anyway the following is intended as an interactive utility to explore
    the callables of modules and classes. I always have it imported into my
    interactive sessions.

    So import it and try

    sm(dict)

    ..########################################################
    ..# sm()
    ..# showmethods
    ..
    ..def sm(namespace,terse=0,maxchars=300):
    ..
    .. """report the callables of a namespace
    ..
    ..returns a nice string representation of the public callables of the
    ..namespace and the first maxchars bytes of their respective docstrings
    ..
    ..if terse, truncates the docstring at the first newline
    .. """
    ..
    .. d = namespace.__dict__
    .. l = [str(x) + "\t\t" + str(d[x].__doc__)[:maxchars] for x in
    d.keys() \
    .. if callable(d[x]) and not x.startswith("_")]
    .. if terse:
    .. l = [x.split("\n")[0] for x in l]
    .. l.sort()
    .. return "\n=====\n".join(l)
    Michael Tobis, Jan 30, 2005
    #2
    1. Advertising

  3. Gabriel B.

    Duncan Booth Guest

    Gabriel B. wrote:

    > Is it just me that can't find a full reference in the docs?
    >
    > I wanted a list of all the methods of dict for example... where can i
    > find it?
    >
    > Thanks, and sorry if this question is just dumb, i really can't find
    > it


    If you want to find out about all the methods of dict then try:

    lib\pydoc.py dict

    from a shell prompt, or

    >>> help(dict)


    from the interactive interpreter.

    The catch is that many of the methods that will be shown aren't really
    relevant to dictionaries, so you will need to ignore the irrelevant ones.

    Run pydoc interactively ('lib\pydoc.py -g') or as a web-server if you want
    to get the output as strangely coloured html. e.g. 'lib\pydoc.py -p 8081'
    then point your browser at 'http://localhost:8081/dict' for help on the
    dict type. (Pick a different port number if 8081 is used on your machine.)

    http://localhost:8081/__builtin__ is a good starting point to browse the
    builtin types, and http://localhost:8081/ will give you an index of all the
    modules installed on your system.
    Duncan Booth, Jan 30, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?a2Q=?=

    Naive question: Crystal reports in ASP.NET

    =?Utf-8?B?a2Q=?=, May 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Peter van der Goes
    May 28, 2005
  2. Matt
    Replies:
    3
    Views:
    484
    Tor Iver Wilhelmsen
    Sep 17, 2004
  3. Frederic

    naive operator new question

    Frederic, Jul 3, 2003, in forum: C++
    Replies:
    0
    Views:
    308
    Frederic
    Jul 3, 2003
  4. Newsgroup - Ann
    Replies:
    1
    Views:
    2,087
    Davlet Panech
    Oct 29, 2003
  5. naive size of array question

    , Nov 21, 2005, in forum: C Programming
    Replies:
    7
    Views:
    304
    Mike Wahler
    Nov 21, 2005
Loading...

Share This Page