In python3, the print() function requires parenthesis. hljs should highlight the "print" keyword, regardless of whether or not it's followed by parentheses, however it does not.
I just looked at the source and saw that print and exec are explicitly excluded when they're used as functions. After reading the code and comment, I can see the justfication for this (that is, when used as a function, it's technically no longer a keyword)
The source commit that caused this for future lookup.
@yyyc514 Can we reopen this issue? I don't want to open a new issue addressing the same stuff as I do wanna ask if this is possible to enable highlighting the print keyword for Python 3.
For example, the print keyword is highlighted on VSCode

Whereas the HighlightJS library doesn't:

Cheers!
I can see the justfication for this (that is, when used as a function, it's technically no longer a keyword)
This made sense to me. But I see it both ways.
Can we get any more Python people to weigh in here?
If isagalaev added it I'm inclined to keep it unless a bunch of Python people tell me otherwise. This was a very intentional change.
Long-term Python people here: print is a keyword in all uses in Python 2, regardless of the presence of parentheses, UNLESS from __future__ import print_function is present at the top of that file, in which case it’s treated as function and _must_ be followed by parentheses. For consistency though print should probably always highlight as a keyword in Python 2.
In Python 3, however, print is, definitely, NOT a keyword, and should be highlighted as per any other function. This is true of exec too, it also ceased to be a keyword. VSCode is incorrect here, and should not be highlighting print as a keyword, as the user can freely overload or shadow it like any other function.
Those are the only two keywords to be removed in the 2 to 3 transition.
Note that new keywords are also added occasionally... the values None, True and False became keywords in Python 3 — though they perform like literal values in all respects as they did previously, except no longer being considered valid, assignable identifiers (True, False = False, True used to work). The nonlocal was added to Python 3 as well. And more recently both async and await were added as of 3.7.
Thanks for the refresher. The sounds vaguely familiar.
In Python 3, however, print is, definitely, NOT a keyword, and should be highlighted as per any other function.
This makes sense to me and since we only have a SINGLE Python grammar I believe it makes sense to go with the newer Python 3 semantics, therefore NO highlighting. @KingDarBoja
If someone wanted to build and release their own Python 2 grammar it seems highlighting print as a keyword would be the correct choice, but that is not where we are here.
Thanks for the explanation, I am glad that yawpitch provided source files to look at.
Everyday I learn something and this was definitely the case, didn't know VSCode was wrong with the highlight until I saw the keyword list on Python 3.
So I do better stick with it as this is the correct behaviour after all.
Cheers!
I don't think VSCode is highlighting print as a keyword? In the code samples provided def, or, None, and class are keywords and they are highlighted in blue. print, however, is highlighted in yellow similarly to @requires_authentication and somefunc, both of which are functions but not keywords.
Personally, I would vote for highlighting print similarly to other functions. The code snippet does not show calling other functions, but I would guess the HighlightJS sample above would use blue?
HLJS generally does not highlight function dispatch, only function definition.
I don't think VSCode is highlighting print as a keyword?
Your right, it doesn't appear to be.
Most helpful comment
Thanks for the refresher. The sounds vaguely familiar.
This makes sense to me and since we only have a SINGLE Python grammar I believe it makes sense to go with the newer Python 3 semantics, therefore NO highlighting. @KingDarBoja
If someone wanted to build and release their own Python 2 grammar it seems highlighting
printas a keyword would be the correct choice, but that is not where we are here.