Skip to main content

Programming fundamentals · Beginner · 16 min

Read the documentation to answer your own questions

By Padding · Updated 18 Nov 2026
Python 3.15.2 · python:3.15-slim (Debian)

You will answer five real programming questions from primary sources (Python's help and pydoc, man and --help, the Python docs, MDN and release notes) and end with a file of five answers, each with the page it came from.

On this page

Every programmer, at every level, looks things up all day. The difference between a beginner and an experienced developer is often not how much they remember but where they look. Search results and forum answers are quick, but they can be old, describe another version, or be wrong. The documentation written by the people who make the tool is the primary source, and it is usually closer than you think: much of it is already on your computer.

In this tutorial you answer five concrete questions using only primary sources:

  1. What does str.split() do when you give it no argument?
  2. Which arguments does sorted() take?
  3. What does ls -t mean?
  4. What does Array.prototype.at() return for -1 in JavaScript?
  5. What changed in the latest Python release?

Along the way you learn to read a function signature, find the examples, check which version a page describes and test a third-party answer against the docs. You finish with a plain text file of five answers, each with the source it came from.

The built-in tools (help, pydoc, man, --help) work offline, which matters if you pay for mobile data by the megabyte: once Python is installed, the first three answers cost no data at all.

Step 1 · Set up a folder and ask Python for help

Make a folder for this tutorial and check that python3 is version 3.15:

Bash
mkdir -p ~/docs-demo
cd ~/docs-demo
python3 --version

If the version is older than 3.15, type python3.15 wherever this tutorial says python3. On Windows outside WSL, type py.

Python carries its own reference. Every built-in function, type and method has a docstring, a short description stored with the code, and help() shows it. Ask about str.split:

Bash
python3 -c "help(str.split)"

The -c option runs the Python code in quotes and exits. You can also start the interactive interpreter with python3 and type help(str.split) at the >>> prompt. In a terminal, long help opens in a pager: use the arrow keys to scroll and press q to leave.

Check it worked

The output starts with a line something like split(self, /, sep=None, maxsplit=-1), followed by a paragraph that describes sep. Somewhere in it you can read that when sep is None, the default, the string is split on any whitespace and empty strings are dropped from the result.

Step 2 · Test what the docs say about str.split

Documentation tells you what should happen. A two-line experiment confirms it on your own machine. The help text made two claims about splitting with no argument: it splits on any whitespace, and it throws away empty pieces. Compare that with splitting on a single space:

Bash
cat > split_test.py <<'PY'
line = "  rent   food\ttransport\n"

print(line.split())
print(line.split(" "))
PY
python3 split_test.py

line holds three words with uneven gaps: two leading spaces, three spaces between the first two words, a tab (\t) and a newline (\n). The first print splits with no argument; the second gives " " as the separator.

Check it worked

The first line is ['rent', 'food', 'transport']: every run of spaces, tabs and newlines counted as one gap, and nothing empty came back. The second line starts ['', '', 'rent', '', '', 'food\ttransport\n']: with an explicit " ", each single space is a cut, so the leading spaces and the extra gaps leave empty strings, and the tab and newline stay inside the last piece. That is your first answer, confirmed.

Step 3 · Read a function signature

The signature is the first line of a help page: the function's name and its parameters. It answers "which arguments does this take?" faster than any paragraph. Look at sorted with pydoc, the command-line form of help:

Bash
python3 -m pydoc sorted

-m pydoc runs the pydoc module from the standard library, and sorted is the name to look up. The top line reads sorted(iterable, /, *, key=None, reverse=False). Read it from left to right:

  • iterable has no default value, so it is required. It is the thing to sort: a list, a string, anything you can loop over.
  • / marks the end of the positional-only parameters. Everything before it must be given by position, never by name, so sorted(iterable=[3, 1]) is not allowed.
  • * marks the start of the keyword-only parameters. Everything after it must be given by name.
  • key=None and reverse=False are optional because they have defaults. key is a function applied to each item before comparing, and reverse=True sorts in descending order.

Now check your reading against the interpreter, including one call the signature says is wrong:

Bash
cat > sorted_test.py <<'PY'
prices = [450, 1200, 75]
words = ["banana", "Apple", "cherry"]

print(sorted(prices))
print(sorted(prices, reverse=True))
print(sorted(words, key=str.lower))
print(sorted(prices, True))
PY
python3 sorted_test.py || echo "exit status $?"

The || echo "exit status $?" part runs only when the script fails, and prints the exit status Python returned.

Check it worked

You see [75, 450, 1200], then [1200, 450, 75], then ['Apple', 'banana', 'cherry'], sorted as if every word were lower case. The last line fails with TypeError: sorted expected 1 argument, got 2, followed by exit status 1. Passing True without the name reverse= broke the rule the * stated. Your second answer: sorted takes one required positional argument and two optional keyword-only ones, key and reverse.

Step 4 · Look up a terminal command with --help and man

Terminal commands document themselves in two ways. Most accept --help, which prints a short summary of options. Many also have a manual page, opened with man, which is longer and more careful. Find -t in the ls summary first:

Bash
ls --help | grep -- ' -t '

The | sends the output of ls --help to grep, which keeps only matching lines. The -- tells grep that the pattern which follows is text to search for, not one of its own options.

Then open the full manual page:

Bash
man ls

Inside man, type /-t and press Enter to search, n to jump to the next match and q to quit. The page starts with NAME, SYNOPSIS and DESCRIPTION sections. The SYNOPSIS line ls [OPTION]... [FILE]... is the signature: square brackets mean optional, and ... means you may give more than one.

Now see the option at work. The demo folder already holds the scripts you wrote today, which would sort ahead of anything else, so make a fresh subfolder for this test. touch -t sets a file's modification time, written as year, month, day, hour and minute:

Bash
mkdir -p ~/docs-demo/dates
cd ~/docs-demo/dates
touch -t 202601010900 january.txt
touch -t 202606010900 june.txt
touch -t 202611010900 november.txt
ls
ls -t
cd ..

The last line, cd .., moves you back up to ~/docs-demo for the rest of the tutorial.

Check it worked

ls --help prints a line something like -t sort by time, newest first; see --time. In the dates folder, plain ls lists the three files in alphabetical order: january.txt, june.txt, november.txt. ls -t lists november.txt first and january.txt last. Your third answer: -t sorts by modification time, newest first.

On macOS, ls is the BSD version: it has no --help, and its manual page words -t differently, but the meaning is the same. This is a small example of why you read the documentation for the tool you actually have. If man reports no manual entry, your system was installed without manual pages; --help and the online manual at man7.org still work.

Step 5 · Check which version a page describes

A correct answer for the wrong version is still wrong. Every good documentation page says which version it covers, and Python's own help links to the matching online page. Ask pydoc about the json module and look for its reference link:

Bash
python3 -m pydoc json | grep -A1 'MODULE REFERENCE'

The -A1 option tells grep to print one line after each match, which is where the address is.

The address contains 3.15: the online page for the same version as your interpreter. On docs.python.org, every page has a version menu at the top, and the address changes with it (/3.14/, /3.15/, /3/ for the newest). When a search engine sends you to a Python docs page, look at that number before reading further.

Now the JavaScript question. The primary source for web JavaScript is MDN Web Docs at developer.mozilla.org, written with browser makers. Search for Array.prototype.at MDN and open the page. Use it like this:

  • The Syntax section is the signature: at(index).
  • Parameters says index is converted to an integer, and that a negative index counts back from the end of the array.
  • Return value says what you get: the element at that position, or undefined if the index is out of range.
  • Examples shows short code you can paste.
  • Browser compatibility, at the bottom, is MDN's version check: a table of which browser versions support the method. Older phones with an outdated browser may lack a newer method, so check it when your users run low-end Android devices that rarely update.

To confirm it yourself, open your browser's developer tools (F12 on most desktop browsers), choose the Console tab, type [10, 20, 30].at(-1) and press Enter.

Check it worked

The grep output shows MODULE REFERENCE followed by https://docs.python.org/3.15/library/json#module-json, the online page for the json module. In the browser console, [10, 20, 30].at(-1) returns 30, and [10, 20, 30].at(5) returns undefined. Your fourth answer: at(-1) returns the last element of the array.

Step 6 · Read the release notes

"What changed?" is answered by release notes. For Python, each version has a page called What's New, at docs.python.org/3.15/whatsnew/3.15.html for 3.15. Open it and read only the top section, the summary of release highlights. Do not try to read the whole page; it is very long and mostly for library authors.

For 3.15, which came out on 9 October 2026, the highlights include:

  • UTF-8 is now the default text encoding (PEP 686).
  • Explicit lazy imports, so a module loads only when first used (PEP 810).
  • A new built-in frozendict type, a dictionary that cannot be changed (PEP 814).
  • Tachyon, a new sampling profiler for finding slow code (PEP 799).

PEP stands for Python Enhancement Proposal: the design document behind each change, linked from the What's New page when you want the full reasoning.

Release notes make claims you can test. Check two of them on your interpreter:

Bash
cat > whats_new_test.py <<'PY'
import sys

print(sys.version_info[:2])
print(sys.flags.utf8_mode)

prices = frozendict(rent=50000, food=20000)
print(prices["rent"])
PY
python3 whats_new_test.py

sys.version_info[:2] is the major and minor version. sys.flags.utf8_mode is 1 when Python's UTF-8 mode is on. The last two lines build a frozendict and read one value from it.

Check it worked

The output is (3, 15), then 1, then 50000. If you run the same script with Python 3.14, it stops at the frozendict line with a NameError, because that version predates the feature. That is your fifth answer, and a reminder that release notes tell you which version you need.

Step 7 · Judge a third-party answer against the docs

Forum posts, blog articles and AI chat answers are useful for pointing you somewhere, but treat each one as a claim to check, never as the answer. Here is a made-up answer of the kind you will meet:

"sorted() sorts your list in place and returns None, so write sorted(prices) on its own line and then print prices."

Check it in two ways. First, the docs: the sorted help you read says it returns a new list. The method that sorts in place and returns None is list.sort. Second, a test:

Bash
cat > claim_test.py <<'PY'
prices = [450, 1200, 75]

result = sorted(prices)
print(result)
print(prices)

print(prices.sort())
print(prices)
PY
python3 claim_test.py

Check it worked

The output is [75, 450, 1200], [450, 1200, 75], None, [75, 450, 1200]. sorted returned a new sorted list and left prices alone; list.sort changed prices and returned None. The answer mixed up the two. A quick way to judge any answer: does it name a version, does it match the official page for your version, and does a three-line test agree?

Step 8 · Write down your answers and sources

An answer without a source is hard to trust later, even when it is your own. Save the five answers with the place each came from:

Bash
cat > answers.txt <<'TXT'
Q1 str.split() with no argument splits on any run of whitespace and drops empty strings.
   Source: help(str.split), Python 3.15; docs.python.org/3.15/library/stdtypes.html#str.split
Q2 sorted(iterable, /, *, key=None, reverse=False): one positional argument, key and reverse by name only.
   Source: python3 -m pydoc sorted; docs.python.org/3.15/library/functions.html#sorted
Q3 ls -t sorts by modification time, newest first.
   Source: ls --help and man ls (GNU coreutils)
Q4 [10, 20, 30].at(-1) returns 30, the last element; out of range returns undefined.
   Source: MDN, Array.prototype.at(), Return value section
Q5 Python 3.15 (9 Oct 2026): UTF-8 by default, lazy imports, frozendict, Tachyon profiler.
   Source: docs.python.org/3.15/whatsnew/3.15.html, summary of release highlights
TXT
grep -c '^Q' answers.txt
grep -c 'Source:' answers.txt

Keep a file like this as you learn. When the same question comes back in a month, you have the answer and the page to reread. If your data is limited, docs.python.org offers the whole Python documentation as a download, so you can read it offline.

Check it worked

Both grep -c commands print 5: five questions, five sources. Run cat answers.txt and check every answer has a page you could open again.

When you are finished, delete the demo folder. rm -rf removes the folder and everything in it without asking and cannot be undone, and that includes answers.txt. Copy your answers to your home folder first:

Bash
cp ~/docs-demo/answers.txt ~/
cd ~
rm -rf ~/docs-demo
ls ~/answers.txt

ls ~/answers.txt prints the path, which shows your answers survived the clean-up.

Next steps

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.