-1

I occasionally use Python and so I forget semantics of basic language constructs. Is there an apt package to install man page of basic Python documentation? My Linux Mint comes only with help of running the interpreter and websearch does not find anything on the subject. I have html version of docs but for quick basic question, like again today I've forgot how to write a for (i=2;i+1;i<10) loop in Python, man page is more convenient to me. TIA

Edit: surprised by downvoting, e.g. Perl has extensive man pages covering the language, bash man page contains script syntax, why Python seems to not have similar?

2 Answers 2

2

You might find pydoc useful. It essentially serves as a CLI interface to the Python documentation, and can work much the same way as, say, an info page. It is a module which often also has a simple wrapper script with the same name, so you could run pydoc <something-in-Python>. For example, on my Arch Linux system, running pydoc for opens up a pager showing:

******************* The "for" statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object: for_stmt ::= "for" target_list "in" starred_list ":" suite ["else" ":" suite] The "starred_list" expression is evaluated once; it should yield an *iterable* object. An *iterator* is created for that iterable. The first item provided by the iterator is then assigned to the target list using the standard rules for assignments (see Assignment statements), and the suite is executed. This repeats for each item provided by the iterator. When the iterator is exhausted, the suite in the "else" clause, if present, is executed, and the loop terminates. A "break" statement executed in the first suite terminates the loop without executing the "else" clause’s suite. A "continue" statement executed in the first suite skips the rest of the suite and continues with the next item, or with the "else" clause if there is no next item. The for-loop makes assignments to the variables in the target list. This overwrites all previous assignments to those variables including those made in the suite of the for-loop: for i in range(10): print(i) i = 5 # this will not affect the for-loop # because i will be overwritten with the next # index in the range [...] 

(This is essentially §8.3 The for statement from the Python documentation.)

That seems Good Enough™.

2
  • I think this is the best option available since Debian has no python documentation package. Commented Nov 30 at 13:56
  • 'pydoc' can be installed on my system by sudo apt install python-dev-is-python3, I think it might suit me. Commented Dec 1 at 2:52
0

like again today I've forgot how to write a for (i=2;i+1;i<10) loop in Python

Then a man page is not what you're looking for! They are for "how do I use this tool", not "how do I write that language"!

The design of man pages derives from service technician manuals (hence the name), something you want to have on hand (… "manual") when you're working on a system that you generally understand, but don't have all the details and service procedures in head. They are not guides on how to learn a language!

(By the way, you mean for (i=2; i<10; i+=1), as in any language with a syntax similar to what you wrote that I'm aware of, the condition is the second, not the third argument. In Pyhton, that is for i in range(2, 10):, and mind your indents.)

Is there an apt package to install man page of basic Python documentation?

No, such pages don't exist, and for good reason. man pages are woefully inadequate for documenting complex languages and standard libraries; the fact that Linux-manpages ships such for the libc is at least partially for historical reasons, to be honest: not even having hyperlinks and "bold" and "underline" being the literally only two options of highlighting things, and that being done inconsistently even within the Linux man-pages project are a testament to that.

You can probably also count the people that actually consult the various PERL man pages regularly on one hand. Having the official documentation available in a browser (and even if it's just a modern TUI browser) is much much more useful than a man page. If you're interested in that discussion, see the comments on this question and its answers (to be honest, I and others shouldn't have commented that much there, we should have taken a bit of that discussion to chat, but now it's there, might as well reference it).

3
  • I use the perl man pages all the time for perl itself and for perl modules. they're excellent documentation, usually including several examples. The perldoc command is also great for getting details on specific functions (extracted from the same docs that are used to generate the man pages), perl APIs, perl variables, FAQs, etc. Commented Nov 30 at 13:38
  • Python docs, OTOH, are severely lacking in detail. It's like they took the "it's meant to be a quick reference, not a tutorial" idea and turned up the dial to 11. No details, no explanation, and certainly no examples, just a very brief summary of the function - and often not much better than something like "foo function does foo". Which might be fine if you already know what "foo" is or means', but completely useless if that's the thing you're trying to find out. The online web docs aren't much better, but there's usually a few brief intro pages. NOT an adequate substitute for decent man pages Commented Nov 30 at 13:42
  • There are quite a few good python books available in epub or pdf format - and some excellent ones are available for free. Great to have. Still not a substitute for good man pages. Commented Nov 30 at 13:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.