In Python, I have seen the yield function used to create a generator many times. Both this function and the print function technically perform the action of the methods because they return a value. However, during the change from Python 2 to Python 3, the print function received brackets, such as a regular method call, but the output remained the same. In addition, yield receives the yellowish color of the reserved keyword, and print receives the purple color of the reserved method. Why is yield not considered by the method and painted in this way without using the syntax in parentheses?
(In the same vein, why return also lacks parentheses?)
Let me add something else, drop it and continue, also the brackets are not indicated in many other languages. I just wanted to know what makes him different. There are many other reserved methods that are enclosed in parentheses.
ytpillai
source share