views:

333

answers:

10

Hello. I'm starting with Python coming from java.

I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.

I've found very helpul to use help( thing ) from the Python ( command line )

I have found this also:

http://docs.python.org/

http://docs.python.org/modindex.html

But it seems to help when you already the class name you are looking for. In JavaDoc API I have all the classes so if I need something I scroll down to a class that "sounds like" what I need. Or some times I just browse all the classes to see what they do, and when I need a feature my brain recalls me We saw something similar in the javadoc remember!?

But I don't seem to find the similar in Python ( yet ) and that why I'm posting this questin.

BTW I know that I would eventually will read this:

http://docs.python.org/lib/lib.html

But, well, I think it is not today.

+5  A: 

pydoc?

I'm not sure if you're looking for something more sophisticated, but it does the trick.

JasonTrue
+1  A: 

Here is a list of all the modules in python, not sure if that's what you're really after.

Harley
Yes I list it on my post.
OscarRyz
A: 

If you're working on Windows ActiveState Python comes with the documentation, including the library reference in a searchable help file.

ConcernedOfTunbridgeWells
+2  A: 

The standard python library is fairly well documented. Try jumping into python and importing a module say "os" and running:

import os   
help(os)

This reads the doc strings on each of the items in the module and displays it. This is exactly what pydoc will do too.

EDIT: epydoc is probably exactly what you're looking for:

Andrew Gwozdziewycz
Yeap, that's what I'm using right now as I said. But Is there a way to browse all the standard classes , like in:http://java.sun.com/javase/6/docs/api/No would be an acceptable answer too :)
OscarRyz
+1  A: 

I've downloaded Python 2.5 from Python.org and It does not contains pydoc.

Directorio de C:\Python25

9/23/2008  10:45 PM    <DIR>          .
9/23/2008  10:45 PM    <DIR>          ..
9/23/2008  10:45 PM    <DIR>          DLLs
9/23/2008  10:45 PM    <DIR>          Doc
9/23/2008  10:45 PM    <DIR>          include
9/25/2008  06:34 PM    <DIR>          Lib
9/23/2008  10:45 PM    <DIR>          libs
2/21/2008  01:05 PM            14,013 LICENSE.txt
2/21/2008  01:05 PM           119,048 NEWS.txt
2/21/2008  01:11 PM            24,064 python.exe
2/21/2008  01:12 PM            24,576 pythonw.exe
2/21/2008  01:05 PM            56,354 README.txt
9/23/2008  10:45 PM    <DIR>          tcl
9/23/2008  10:45 PM    <DIR>          Tools
2/21/2008  01:11 PM             4,608 w9xpopen.exe
          6 archivos        242,663 bytes

But it has ( the substitute I guess ) pydocgui...

C:\Python25>dir Tools\Scripts\pydocgui.pyw

10/28/2005  07:06 PM               222 pydocgui.pyw
           1 archivos            222 bytes

This launches a webserver and shows what I was looking for. All the modules plus all the classes that come with the platform.

The Doc dir contains the same as in:

http://docs.python.org/

Thanks a lot for guide me to pydoc.

OscarRyz
+1  A: 

BTW I know that I would eventually will read this:

http://docs.python.org/lib/lib.html

But, well, I think it is not today.

I suggest that you're making a mistake. The lib doc has "the class, its methods and and example of how to use it." It is what you are looking for.

I use both Java and Python all the time. Dig into the library doc, you'll find everything you're looking for.

S.Lott
Yes I know. But when it comes to try to figure out what a method signature is, it is not very helpful to go en browse that file, go down , up etc. I'm not saying I won't read it. It looks pretty interesting. But.. the day will come :P Thanks 1+ for you.
OscarRyz
"it is not very helpful to go en browse that file, go down , up etc." What? What are you talking about? It's a web site. Bookmark it.
S.Lott
I'm talking that when looking for a method signature, scanning through the whole document is not at least for the the fastest way to get the answer. That's all.
OscarRyz
I totally agree that searching is slow. I use Google and bookmarks; they're fast.
S.Lott
A: 

It doesn't directly answer your question (so I'll probably be downgraded), but you may be interested in Jython.

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

Since you are coming from Java, Jython may help you leverage Python while still allowing you to use your Java knowledge.

crystalattice
It's ok. I tried Jython before. but since the Java api is there I'm just actually using java in some other language, which is fine, if what I need is integration. But in my case I'm looking for documentation on the Python platform itself. Pydoc is what I needed. Thanks.
OscarRyz
A: 

You can set the environment variable PYTHONDOCS to point to where the python documentation is installed.

On my system, it's in /usr/share/doc/python2.5

So you can define this variable in your shell profile or somewhere else depending on your system:

export PYTHONDOCS=/usr/share/doc/python2.5

Now, if you open an interractive python console, you can call the help system. For exemple:

>>> help(Exception)
>>> Help on class Exception in module exceptions:

>>> class Exception(BaseException)
>>>  |  Common base class for all non-exit exceptions.
>>>  |  
>>>  |  Method resolution order:
>>>  |      Exception

Documentation is here:

http://docs.python.org/lib/module-pydoc.html

Oli
A: 

Also try

pydoc -p 11111

Then type in web browser http://localhost:11111

EDIT: of course you can use any other value for port number instead of 11111

Sergei Stolyarov
A: 

I'm having exactly the same problem. PHP has great searchable documentation for when you don't know the class or method you're looking for.

I've tried pydoc, but again it seems to rely on me knowing which class the method is in that I want.

Is there no official online searchable documentation for Python 2.7 anywhere?

timmy