Python language API [closed]
-
02-07-2019 - |
Question
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:
https://docs.python.org/2/py-modindex.html
But it seems to help when you already have 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:
https://docs.python.org/2/library/
But, well, I think it is not today.
Solution
I'm not sure if you're looking for something more sophisticated, but it does the trick.
OTHER TIPS
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:
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:
Thanks a lot for guide me to pydoc.
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.
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:
Here is a list of all the modules in Python, not sure if that's what you're really after.
If you're working on Windows ActiveState Python comes with the documentation, including the library reference in a searchable help file.
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
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.