8000 bpo-38558: Link to further docs from walrus operator mention in tutor… · python/cpython@5807efd · GitHub
[go: up one dir, main page]

Skip to content

Commit 5807efd

Browse files
authored
bpo-38558: Link to further docs from walrus operator mention in tutorial (GH-16973)
1 parent 49932fe commit 5807efd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Doc/faq/design.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ variables and instance variables live in two different namespaces, and you need
148148
to tell Python which namespace to use.
149149

150150

151+
.. _why-can-t-i-use-an-assignment-in-an-expression:
152+
151153
Why can't I use an assignment in an expression?
152154
-----------------------------------------------
153155

Doc/tutorial/datastructures.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,10 @@ to a variable. For example, ::
676676
'Trondheim'
677677

678678
Note that in Python, unlike C, assignment inside expressions must be done
679-
explicitly with the walrus operator ``:=``. This avoids a common class of
680-
problems encountered in C programs: typing ``=`` in an expression when ``==``
681-
was intended.
679+
explicitly with the
680+
:ref:`walrus operator <why-can-t-i-use-an-assignment-in-an-expression>` ``:=``.
681+
This avoids a common class of problems encountered in C programs: typing ``=``
682+
in an expression when ``==`` was intended.
682683

683684

684685
.. _tut-comparing:

0 commit comments

Comments
 (0)
0