Syntax highlighting works only on function, class and method definitions?

 

 

 

Hi,
Why syntax highlighting works only on function, class and method definitions? is there any way setting up Pycharm like VS? 

Thanks!

 

 

3 comments

I think in this case, PyCharm is doing the right thing. Your code won't run in Python and would get flagged in pylint:

TypeError: unbound method myfunction() must be called with MyClass instance as first argument (got nothing instead)

In PyCharm, the ")" is highlighted, meaning PyCharm is giving you a warning. If you mouse over the ")", you'll see that it says: "Parameter self is unfilled". This is because you are calling "myfunction" without making an instance of the class. Several ways to fix this:

  • MyClass().myfunction()
  • def myfunction(self=None)
  • @staticmethod
    def bar():

Thus, VS2015 is telling you your Python is fine, when in fact, it won't run.

 

1

I understand, thanks! What about color highlighting? Why function and class does not color highlighting after their definition?

1

I have never really noticed because i have been using PyCharm since i started programming. But Arsen is 100% correct. PyCharm doesn't differentiate almost anything while writing execution code. 

 

A line like

some_module.some_function(SomeClass, some_var)

with that many different syntax types in all other "good" IDE's would have distinct visual syntax highlights. In PyCharm that entire line is the same color. 

I would even argue this is more important to python that most languages because there is no type info to help. Makes syntax highlighting that much more important.

1

Please sign in to leave a comment.