What does this use of << mean in Python

无人久伴 提交于 2019-12-02 00:14:50

Like any operator, << can be overloaded by classes to define their own behavior. The example you give looks like it's from code using pyparsing. This is a parser library that overloads operators in this way. The << here updates the content of a previously-defined placeholder token. Read the documentation on pyparsing for more about how this works.

The bottom line is that << can mean anything, just like + or < can mean anything, because the behavior of operators is determined by the types of the objects they operate on. You have to know the types of the objects to understand the behavior.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!