aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/controlflow.rst5
-rw-r--r--Doc/tutorial/index.rst7
-rw-r--r--Doc/tutorial/introduction.rst7
-rw-r--r--Doc/tutorial/modules.rst6
4 files changed, 16 insertions, 9 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 95939242fb7..5c0e8f34bf8 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -999,7 +999,8 @@ scope::
43
The above example uses a lambda expression to return a function. Another use
-is to pass a small function as an argument::
+is to pass a small function as an argument. For instance, :meth:`list.sort`
+takes a sorting key function *key* which can be a lambda function::
>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> pairs.sort(key=lambda pair: pair[1])
@@ -1055,7 +1056,7 @@ Here is an example of a multi-line docstring::
>>> print(my_function.__doc__)
Do nothing, but document it.
- No, really, it doesn't do anything.
+ No, really, it doesn't do anything.
.. _tut-annotations:
diff --git a/Doc/tutorial/index.rst b/Doc/tutorial/index.rst
index 96791f88c86..d0bf77dc40d 100644
--- a/Doc/tutorial/index.rst
+++ b/Doc/tutorial/index.rst
@@ -4,6 +4,10 @@
The Python Tutorial
######################
+.. Tip:: This tutorial is designed for
+ *programmers* that are new to the Python language,
+ **not** *beginners* who are new to programming.
+
Python is an easy to learn, powerful programming language. It has efficient
high-level data structures and a simple but effective approach to
object-oriented programming. Python's elegant syntax and dynamic typing,
@@ -21,7 +25,8 @@ implemented in C or C++ (or other languages callable from C). Python is also
suitable as an extension language for customizable applications.
This tutorial introduces the reader informally to the basic concepts and
-features of the Python language and system. It helps to have a Python
+features of the Python language and system. Be aware that it expects you to
+have a basic understanding of programming in general. It helps to have a Python
interpreter handy for hands-on experience, but all examples are self-contained,
so the tutorial can be read off-line as well.
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index cdb35da7bc9..9e06e03991b 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -13,10 +13,9 @@ end a multi-line command.
.. only:: html
- You can toggle the display of prompts and output by clicking on ``>>>``
- in the upper-right corner of an example box. If you hide the prompts
- and output for an example, then you can easily copy and paste the input
- lines into your interpreter.
+ You can use the "Copy" button (it appears in the upper-right corner
+ when hovering over or tapping a code example), which strips prompts
+ and omits output, to copy and paste the input lines into your interpreter.
.. index:: single: # (hash); comment
diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst
index de7aa0e2342..47bf7547b4a 100644
--- a/Doc/tutorial/modules.rst
+++ b/Doc/tutorial/modules.rst
@@ -27,14 +27,16 @@ called :file:`fibo.py` in the current directory with the following contents::
# Fibonacci numbers module
- def fib(n): # write Fibonacci series up to n
+ def fib(n):
+ """Write Fibonacci series up to n."""
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
- def fib2(n): # return Fibonacci series up to n
+ def fib2(n):
+ """Return Fibonacci series up to n."""
result = []
a, b = 0, 1
while a < n: