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

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
Avatar
Permanently deleted user

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

1
Avatar
Permanently deleted user

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.

4

This is possible by now

0

Matan Is it? I can't for the life of me figure out how to get this to work. I'm using PyCharm 2023.2.5 (Community Edition) I've tried messing around in the settings but despite finding an entry for Class reference and changing it's color I'm not seeing any difference in my code:

0

请先登录再写评论。