PEP 622: drop restriction on ._ an _.a
This commit is contained in:
parent
30592da944
commit
410ba6dd48
27
pep-0622.rst
27
pep-0622.rst
|
@ -317,15 +317,6 @@ adding it is not prohibited, so ``.Color.BLACK`` is the same as ``Color.BLACK``.
|
|||
See `rejected ideas`_ for other syntactic alternatives that were considered
|
||||
for constant value pattern.
|
||||
|
||||
The initial name must not be ``_`` because ``_`` has a special meaning in
|
||||
pattern matching, so these are invalid::
|
||||
|
||||
case ._: ...
|
||||
case _.a: ...
|
||||
|
||||
However, ``a._`` is legal and loads the attribute with name ``_`` of the
|
||||
object ``a`` as usual.
|
||||
|
||||
|
||||
.. _sequence_pattern:
|
||||
|
||||
|
@ -1404,6 +1395,24 @@ provide the *values* for all positional arguments at once. And there
|
|||
seems to be no practical need for it, so it was scrapped. (It could
|
||||
easily be added at a later stage if a need arises.)
|
||||
|
||||
Disallow ``._`` and ``_.a`` in constant value patterns
|
||||
------------------------------------------------------
|
||||
|
||||
The first public draft said that the initial name in a constant value
|
||||
pattern must not be ``_`` because ``_`` has a special meaning in
|
||||
pattern matching, so these would be invalid::
|
||||
|
||||
case ._: ...
|
||||
case _.a: ...
|
||||
|
||||
(However, ``a._`` would be legal and load the attribute with name
|
||||
``_`` of the object ``a`` as usual.)
|
||||
|
||||
There was some pushback against this on python-dev (some people have a
|
||||
legitimate use for ``_`` as an important global variable, esp. in
|
||||
i18n) and the only reason for this prohibition was to prevent some
|
||||
user confusion. But it's not the hill to die on.
|
||||
|
||||
|
||||
.. _deferred ideas:
|
||||
|
||||
|
|
Loading…
Reference in New Issue