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/interpreter.rst6
-rw-r--r--Doc/tutorial/introduction.rst9
-rw-r--r--Doc/tutorial/modules.rst6
-rw-r--r--Doc/tutorial/stdlib.rst2
-rw-r--r--Doc/tutorial/stdlib2.rst2
7 files changed, 23 insertions, 14 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/interpreter.rst b/Doc/tutorial/interpreter.rst
index 02e7de77322..cd526071424 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -16,7 +16,7 @@ Unix shell's search path makes it possible to start it by typing the command:
.. code-block:: text
- python3.14
+ python3.15
to the shell. [#]_ Since the choice of the directory where the interpreter lives
is an installation option, other places are possible; check with your local
@@ -97,8 +97,8 @@ before printing the first prompt:
.. code-block:: shell-session
- $ python3.14
- Python 3.14 (default, April 4 2024, 09:25:04)
+ $ python3.15
+ Python 3.15 (default, May 7 2025, 15:46:04)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index bec5da8fd75..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
@@ -147,6 +146,8 @@ Python can manipulate text (represented by type :class:`str`, so-called
"``Yay! :)``". They can be enclosed in single quotes (``'...'``) or double
quotes (``"..."``) with the same result [#]_.
+.. code-block:: pycon
+
>>> 'spam eggs' # single quotes
'spam eggs'
>>> "Paris rabbit got your back :)! Yay!" # double quotes
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:
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst
index 4b3eef313e7..d83ecca270b 100644
--- a/Doc/tutorial/stdlib.rst
+++ b/Doc/tutorial/stdlib.rst
@@ -15,7 +15,7 @@ operating system::
>>> import os
>>> os.getcwd() # Return the current working directory
- 'C:\\Python314'
+ 'C:\\Python315'
>>> os.chdir('/server/accesslogs') # Change current working directory
>>> os.system('mkdir today') # Run the command mkdir in the system shell
0
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index a2f96b34b2d..678b71c9274 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -279,7 +279,7 @@ applications include caching objects that are expensive to create::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
d['primary'] # entry was automatically removed
- File "C:/python314/lib/weakref.py", line 46, in __getitem__
+ File "C:/python315/lib/weakref.py", line 46, in __getitem__
o = self.data[key]()
KeyError: 'primary'