Python中的'@ ='符号是什么? [英] What is the '@=' symbol for in Python?

查看:286
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆