2525.. code-block :: python
2626
2727 # a.b?.c
28- _t1 .c if ((_t1 := a.b) is not None ) else None
28+ _t .c if ((_t := a.b) is not None ) else None
2929
3030 # a.b?[c]
31- _t1 [c] if ((_t1 := a.b) is not None ) else None
31+ _t [c] if ((_t := a.b) is not None ) else None
3232
3333 See the `Specification `_ section for more details.
3434
@@ -416,13 +416,22 @@ The maybe-dot and maybe-subscript operators
416416-------------------------------------------
417417
418418Two new operators are added, ``?. `` ("maybe-dot") and ``?[ ] ``
419- ("maybe subscript"). Both operators first evaluate the left hand side.
420- The result is stored in a temporary variable, so that the expression is not
421- evaluated again. It is checked if the result is not `` None `` and only then
422- is the remaining expression evaluated as if normal attribute or subscript
423- access were used.
419+ ("maybe subscript"). Both operators first evaluate the left hand side
420+ (the `` base ``). The result is stored in a temporary variable, so that
421+ the expression is not evaluated again. It is checked if the result is
422+ not `` None `` and only then is the remaining expression (the `` tail ``)
423+ evaluated as if normal attribute or subscript access were used.
424424
425- ::
425+ .. code-block :: python
426+
427+ # base?.tail
428+ (_t.tail) if ((_t := base) is not None ) else None
429+
430+ The ``base `` can be replace with any number of expressions, including
431+ `Groups `_ while the ``tail `` is limited to attribute access, subscript,
432+ their ``None ``-aware variants and call expressions.
433+
434+ .. code-block :: python
426435
427436 # a.b?.c
428437 _t.c if ((_t := a.b) is not None ) else None
@@ -441,12 +450,13 @@ access were used.
441450 Short-circuiting
442451****************
443452
444- If the left hand side for ``?. `` or ``?[ ] `` evaluate to ``None ``, the
445- remaining expression is skipped and the result will be set to ``None ``
446- instead. The ``AttributeError `` for accessing a member of ``None `` or
447- ``TypeError `` for trying to subscribe to ``None `` are omitted. It is
448- therefore not necessary to change ``. `` or ``[ ] `` on the right hand side
449- just because a ``?. `` or ``?[ ] `` is used prior.
453+ If the left hand side (the ``base ``) for ``?. `` or ``?[ ] `` evaluate to
454+ ``None ``, the remaining expression (the ``tail ``) is skipped and the
455+ result will be set to ``None `` instead. The ``AttributeError `` for
456+ accessing a member of ``None `` or ``TypeError `` for trying to subscribe
457+ to ``None `` are omitted. It is therefore not necessary to change ``. ``
458+ or ``[ ] `` on the right hand side just because a ``?. `` or ``?[ ] `` is
459+ used prior.
450460
451461::
452462
0 commit comments