Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > naive doc question

Reply
Thread Tools

naive doc question

 
 
Gabriel B.
Guest
Posts: n/a
 
      01-30-2005
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
 
Reply With Quote
 
 
 
 
Michael Tobis
Guest
Posts: n/a
 
      01-30-2005
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_i...ihelper.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)

 
Reply With Quote
 
 
 
 
Duncan Booth
Guest
Posts: n/a
 
      01-30-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naive question about dialling codes on VOIP usenet@isbd.co.uk UK VOIP 11 01-20-2006 07:23 PM
Naive question: Crystal reports in ASP.NET =?Utf-8?B?a2Q=?= ASP .Net 1 05-28-2005 02:23 PM
Re: naive doc question Brian van den Broek Python 2 01-30-2005 01:41 AM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
Naive question on megapixels Ed Johnson Digital Photography 16 12-06-2003 03:45 AM



Advertisments