PEP 614: Remove matmul section and clarify the current restrictions (#1305)

This commit is contained in:
Brandt Bucher 2020-02-13 11:55:28 -08:00 committed by GitHub
parent 85c431c827
commit b34adc092e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 26 deletions

View File

@ -9,15 +9,16 @@ Type: Standards Track
Content-Type: text/x-rst
Created: 10-Feb-2020
Python-Version: 3.9
Post-History: 10-Feb-2020
Post-History: 11-Feb-2020
Resolution:
Abstract
========
This PEP proposes allowing functions and classes to be decorated with
any valid expression.
Python currently requires that all decorators consist of a dotted
name, optionally followed by a single call. This PEP proposes removing
these limitations and allowing decorators to be any valid expression.
Motivation
@ -193,29 +194,6 @@ This new grammar is fully backward-compatible with the existing
grammar.
Binary Matrix Multiplication
----------------------------
One interesting case is the binary ``@`` operator, which was added to
the language after decorators were first introduced. With the proposed
change to the grammar, the following decorator expression will be
unambiguous legal syntax::
@a @ b
def f():
...
However, this pathological case is unlikely to occur in practice, as
there are no known examples of binary matrix multiplication results
which may used as decorators. Likely the only people who would do this
are those who currently write similarly obfuscated toy code::
@_(a
@b)
def f():
...
How To Teach This
=================