Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I see the Python doc on Linux?

Tags:

python

linux

doc

In Windows, Python has a chm type document, and it is very convenient to read. But in the Linux, is there any document let me to read?

like image 929
Tanky Woo Avatar asked Mar 22 '12 06:03

Tanky Woo


People also ask

How do I access Python documentation?

How to access that? Use help() command in python' shell. In the shell, type command help() . Now that you're in the help utility, enter anything that you want to read its documentation.

Does Python have documentation?

reStructuredText. Most Python documentation is written with reStructuredText. It's like Markdown, but with all the optional extensions built in. The reStructuredText Primer and the reStructuredText Quick Reference should help you familiarize yourself with its syntax.

Does Linux come with Python?

1. On Linux. Python comes preinstalled on most Linux distributions, and is available as a package on all others.

What does Pydoc command do?

Similar to the functionality of Perldoc within Perl and Javadoc within Java, Pydoc allows Python programmers to access Python's documentation help files, generate text and HTML pages with documentation specifics, and find the appropriate module for a particular job.


1 Answers

Online documentation

The simplest way is to use Google to get to online documentation. There is no single point where you find all documentations of all modules. However, a few common ones are:

  • Python 3
  • NumPy and SciPy
  • Theano

If you need offline documentation there are a few other possibilities:

Download it

You can download the documentation as HTML or a PDF: https://docs.python.org/3/download.html

When you have a web server running, you can use the HTML version and access it as you are used to via a browser. The HTML site looks just like you are used to. Even the search works offline, because it is implemented with JavaScript.

enter image description here

PyDoc

Some distributions like Debian offer a python-doc package. You can access it via pydoc -p [some port number] or via pydoc -g. This will create a local web server. Then you can open your browser and have a look at it:

enter image description here

Console: help(...)

The Python interactive console has a built-in help(...) system. You can either invoke it without an argument:

$ python Python 2.7.5+ (default, Feb 27 2014, 19:37:08)  [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> help()  Welcome to Python 2.7!  This is the online help utility.  If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.  Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules.  To quit this help utility and return to the interpreter, just type "quit".  To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics".  Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam".  help>  

or you can call it with a paramter about which you want to know something. That can be anything (a module, a class, a function, an object, ...). It looks like this:

>>> a = {'b':'c'} >>> help(a) Help on dict object:  class dict(object)  |  dict() -> new empty dictionary  |  dict(mapping) -> new dictionary initialized from a mapping object's  |      (key, value) pairs  |  dict(iterable) -> new dictionary initialized as if via:  |      d = {}  |      for k, v in iterable:  |          d[k] = v  |  dict(**kwargs) -> new dictionary initialized with the name=value pairs  |      in the keyword argument list.  For example:  dict(one=1, two=2)  |    |  Methods defined here:  |    |  __cmp__(...)  |      x.__cmp__(y) <==> cmp(x,y)  |    |  __contains__(...)  |      D.__contains__(k) -> True if D has a key k, else False  |    |  __delitem__(...)  |      x.__delitem__(y) <==> del x[y]  |    |  __eq__(...)  |      x.__eq__(y) <==> x==y  |    |  __ge__(...)  |      x.__ge__(y) <==> x>=y  |    |  __getattribute__(...)  |      x.__getattribute__('name') <==> x.name  |    |  __getitem__(...)  |      x.__getitem__(y) <==> x[y]  |    |  __gt__(...) : (scroll) 
like image 145
Martin Thoma Avatar answered Oct 03 '22 19:10

Martin Thoma