31

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?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Tanky Woo
  • 4,906
  • 9
  • 44
  • 75
  • Can't you just search the [Python documentation website](http://docs.python.org/index.html)? Also, Google is quite good at finding the right documentation. – Some programmer dude Mar 22 '12 at 07:04
  • 3
    to Joachim Pileborg.sorry, the net here is ever bad, so that is why I need the offline doc. – Tanky Woo Mar 22 '12 at 07:23
  • One day I'd forgotten how to start the PyDoc localhost server thingy. I started searching around the Python documentation website, but didn't get very far. So I turned to Stack Exchange, and one of the answers here gave me what I was after. So maybe we should keep the question. – D A Vincent Nov 03 '16 at 10:14
  • I would point out that not all Python development environments have live access to the Internet. – user3481644 Mar 05 '23 at 15:30

9 Answers9

22

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:

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)
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • 1
    `pydoc` can also be used with no flags in which case the output goes into `less` (similarly to `man`). For example try `pydoc os.path`. – dshepherd Apr 21 '15 at 16:41
10

http://www.google.cz/search?q=linux+chm+viewer

The docs are available in various formats: http://docs.python.org/download.html

There is a python documentation server, which you can run locally: http://docs.python.org/library/pydoc.html?highlight=pydoc#pydoc

Krab
  • 2,118
  • 12
  • 23
6

If you use the Fedora distribution, then yum install python-docs. Other distributions may provide similar packages.

wks
  • 1,158
  • 1
  • 7
  • 12
5

You can also install the Ipython to inspect the modules/objects in the interactive mode.
For example, you can do this in ipython:

import pygame  
pygame.draw.line?

then you get the result doc:

pygame.draw.line(Surface, color, start_pos, end_pos, width=1): return Rect
draw a straight line segment

In ipython you can use tab complition, it's helpful for inspecting something.

Ray
  • 1,647
  • 13
  • 16
4

Best way is to read the documentation built into Python shell.

$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
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/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> 
ronakg
  • 4,038
  • 21
  • 46
  • The difficulty with the built in help is that there is no help function (that I can find), which makes it difficult to browse the help if you don't know what you're looking for. R has a really nice `??topic` search method that looks though all available libraries. Is there anything similar for python? – naught101 Oct 15 '13 at 00:57
3

For python < 3.3 use the following command

pydoc -g
python -m pydoc -g

For python after 3.3

pydoc -b
python -m pydoc -b
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Zaki
  • 158
  • 1
  • 7
3

I think the best alternative is to use DevDocs

  • plus it is offline
  • plus it has a desktop app as well
Zablon
  • 117
  • 1
  • 4
1
  • System Ubuntu 18.04

To view offline documentation for Python,

  1. install python3-doc with sudo apt install python3-doc . The documents are installed at /usr/share/doc/python3-doc/html
  2. Open /usr/share/doc/python3-doc/html/index.html with a web browser.

The documents are just as presented on the official document site: https://docs.python.org/3/

liginity
  • 311
  • 3
  • 7
-2

Since you're on the Internet take advantage of the online python docs.

SpliFF
  • 38,186
  • 16
  • 91
  • 120
  • 4
    Since this doesn't answer the question, and it's just a link, it should be a comment. – agf Mar 22 '12 at 07:01
  • 4
    of course it answers the question, he wants to read the docs on linux and there's the docs. you want me to spell out he needs to use a browser? – SpliFF Mar 22 '12 at 07:12
  • 1
    sorry, it is my fault, I don't say it complete.I need a offline doc. – Tanky Woo Mar 22 '12 at 07:27
  • 1
    You are making an assumption that most of us are on-line. There are many developers in secure facilities and other places which have zero Internet connectivity. Ubiquitous, yes. Everywhere, no. – Not a machine Mar 30 '19 at 22:26