mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-38558: Link to further docs from walrus operator mention in tutorial (GH-16973)
This commit is contained in:
parent
49932fec62
commit
5807efd4c3
2 changed files with 6 additions and 3 deletions
|
@ -148,6 +148,8 @@ variables and instance variables live in two different namespaces, and you need
|
||||||
to tell Python which namespace to use.
|
to tell Python which namespace to use.
|
||||||
|
|
||||||
|
|
||||||
|
.. _why-can-t-i-use-an-assignment-in-an-expression:
|
||||||
|
|
||||||
Why can't I use an assignment in an expression?
|
Why can't I use an assignment in an expression?
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -676,9 +676,10 @@ to a variable. For example, ::
|
||||||
'Trondheim'
|
'Trondheim'
|
||||||
|
|
||||||
Note that in Python, unlike C, assignment inside expressions must be done
|
Note that in Python, unlike C, assignment inside expressions must be done
|
||||||
explicitly with the walrus operator ``:=``. This avoids a common class of
|
explicitly with the
|
||||||
problems encountered in C programs: typing ``=`` in an expression when ``==``
|
:ref:`walrus operator <why-can-t-i-use-an-assignment-in-an-expression>` ``:=``.
|
||||||
was intended.
|
This avoids a common class of problems encountered in C programs: typing ``=``
|
||||||
|
in an expression when ``==`` was intended.
|
||||||
|
|
||||||
|
|
||||||
.. _tut-comparing:
|
.. _tut-comparing:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue