Python中的'@ ='符号是什么? [英] What is the '@=' symbol for in Python?
问题描述
我知道@
是用于装饰器的,但是@=
在Python中是什么?只是保留一些未来的想法吗?
I know @
is for decorators, but what is @=
for in Python? Is it just reservation for some future idea?
这只是我阅读tokenizer.py
时遇到的许多问题之一.
This is just one of my many questions while reading tokenizer.py
.
推荐答案
来自文档:
@
(at)运算符旨在用于矩阵乘法.没有内置的Python类型实现此运算符.
The
@
(at) operator is intended to be used for matrix multiplication. No builtin Python types implement this operator.
@
运算符是Python 3.5中引入的.如您所料,@=
是矩阵乘法,后跟赋值.它们映射到__matmul__
,__rmatmul__
或__imatmul__
,类似于+
和+=
映射到__add__
,__radd__
或__iadd__
的方式.
The @
operator was introduced in Python 3.5. @=
is matrix multiplication followed by assignment, as you would expect. They map to __matmul__
, __rmatmul__
or __imatmul__
similar to how +
and +=
map to __add__
, __radd__
or __iadd__
.
PEP 465 .
这篇关于Python中的'@ ='符号是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!