Color Coding Functions

40 views
Skip to first unread message

Blue Owl

unread,
Nov 21, 2022, 12:36:11 PM11/21/22
to PyScripter
When I create a function, by default PyScripter will change the color of the function to red.  Cool.  This is what I want.

But when I use that function later in the script, it's just plain white text.

Example:

def openFile (filename):  # note the function is in red text. 
    code....

openFile(filename) # note the function is NOT colored at all.

This is making my code harder to read/decipher.

Any fixes? 

PyScripter

unread,
Nov 21, 2022, 7:16:12 PM11/21/22
to PyScripter
I am not sure what you are referring to.  Could you provide a complete example with some screenshots?
Also, which version of PyScripter are you using?

Blue Owl

unread,
Nov 21, 2022, 7:55:10 PM11/21/22
to PyScripter
Sure.  Here's a screenshot from Visual Studio Code (first pic below).  The function name is color coded as is the subsequent function call at the bottom of the example code.   But in PyScripter (the 2nd picture), the function isn't color coded when it's called, only after it's defined.  Is there a way that every occurrence of a function would get color coded?

VSC_Example_Function_ColorCoding.jpgPyScripter_Example_Function_ColorCoding.jpg

Blue Owl

unread,
Nov 21, 2022, 7:55:52 PM11/21/22
to PyScripter
Oh, and I'm using version 4.1.1.0.

PyScripter

unread,
Nov 21, 2022, 8:12:51 PM11/21/22
to PyScripter
Interesting.  My VS Code does not color function calls.
VSC.png


PyScripter does a make the distinction between function names and other identifiers, except in the definition of classes and functions.   You can customize the coloring of identifiers, but you cannot show differently function calls from other identifiers (variables). This may be implemented in the future.

Blue Owl

unread,
Nov 21, 2022, 8:15:31 PM11/21/22
to PyScripter
Someone mentioned that maybe a linter would do this?  I'm new to programming so I'm not exactly sure where I'd start here.  Is that something that could work here?

jf...@ms4.hinet.net

unread,
Nov 21, 2022, 8:20:37 PM11/21/22
to PyScripter
I think it's a normal behavior to color coded the function name at definition only, not everywhere else. What to do when it appears in a comment, in class, or even as a local variable?

readys...@gmail.com 在 2022年11月22日 星期二凌晨1:36:11 [UTC+8] 的信中寫道:

PyScripter

unread,
Nov 21, 2022, 8:23:26 PM11/21/22
to PyScripter
This is syntax highlighting.  PyScripter uses its own python syntax highlighter.   Implementing the different coloring of function calls is not very hard, but you are the first to request that.
If you want to contribute to the project you can help by for instance:

  • hanging around and asking/answering questions here
  • submitting feature requests and bug reports at the project repo.
  • helping with translations and documentation

Blue Owl

unread,
Nov 21, 2022, 8:59:55 PM11/21/22
to PyScripter
Ah.  Well thank you for looking into this and getting back to me.

As mentioned, I'm new to programming, have only used VSC aside from PyScripter, and don't really know what's standard and what isn't.  Visual Studio Code was extremely difficult to get working with some GDAL stuff (spatial/image/vector analysis if you aren't familiar), which I'm currently working on, and was looking for an alternative.  PyScripter was recommended as being a great lightweight alternative.  I still like it, but did enjoy the function call highlighting in VSC.  Interesting that your version of VSC didn't seem to do it.

Since I am so new, I'm not sure I'd be a lot of help around here.

Thank you again.

peet....@gmail.com

unread,
Nov 22, 2022, 9:07:06 AM11/22/22
to pyscr...@googlegroups.com

 

 

Sometimes, as I enter code, PyScripter flags syntax errors that aren’t real (see above).  However, the code runs fine – there are no errors.  The code above was entered in one continuous input, line by line.

 

Running the code leaves the ‘error squiggles’ intact.

 

But, taking that ‘break’ as an example, if, at the end of the code, I go and un-indent and then re-indent the break, the squiggles disappear.

 

Any ideas?

 

Peet

 

From: pyscr...@googlegroups.com <pyscr...@googlegroups.com> On Behalf Of PyScripter
Sent: 22 November 2022 01:23
To: PyScripter <pyscr...@googlegroups.com>
Subject: Re: Color Coding Functions

 

This is syntax highlighting.  PyScripter uses its own python syntax highlighter.   Implementing the different coloring of function calls is not very hard, but you are the first to request that.

If you want to contribute to the project you can help by for instance:

 

  • hanging around and asking/answering questions here
  • submitting feature requests and bug reports at the project repo.
  • helping with translations and documentation

 

On Tuesday, November 22, 2022 at 3:15:31 AM UTC+2 readys...@gmail.com wrote:

Someone mentioned that maybe a linter would do this?  I'm new to programming so I'm not exactly sure where I'd start here.  Is that something that could work here?

On Tuesday, November 22, 2022 at 1:12:51 AM UTC PyScripter wrote:

Interesting.  My VS Code does not color function calls.

 

 

PyScripter does a make the distinction between function names and other identifiers, except in the definition of classes and functions.   You can customize the coloring of identifiers, but you cannot show differently function calls from other identifiers (variables). This may be implemented in the future.

On Tuesday, November 22, 2022 at 2:55:10 AM UTC+2 readys...@gmail.com wrote:

Sure.  Here's a screenshot from Visual Studio Code (first pic below).  The function name is color coded as is the subsequent function call at the bottom of the example code.   But in PyScripter (the 2nd picture), the function isn't color coded when it's called, only after it's defined.  Is there a way that every occurrence of a function would get color coded?

 

 

On Tuesday, November 22, 2022 at 12:16:12 AM UTC PyScripter wrote:

I am not sure what you are referring to.  Could you provide a complete example with some screenshots?

Also, which version of PyScripter are you using?

On Monday, November 21, 2022 at 7:36:11 PM UTC+2 readys...@gmail.com wrote:

When I create a function, by default PyScripter will change the color of the function to red.  Cool.  This is what I want.

 

But when I use that function later in the script, it's just plain white text.

 

Example:

 

def openFile (filename):  # note the function is in red text. 

    code....

 

openFile(filename) # note the function is NOT colored at all.

 

This is making my code harder to read/decipher.

 

Any fixes? 

--
You received this message because you are subscribed to the Google Groups "PyScripter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyscripter+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyscripter/0172b6ab-0f7d-462a-8b92-80ed00d46b57n%40googlegroups.com.

image001.png

peet....@gmail.com

unread,
Nov 22, 2022, 9:08:44 AM11/22/22
to pyscr...@googlegroups.com

Sorry, didn’t trim off previous question!

image001.png

Albert Prauser

unread,
Nov 22, 2022, 10:55:06 AM11/22/22
to pyscr...@googlegroups.com
Hello,
There is a missing operation between if and brake.

Type between if and brake pass.

If ....
    pass   #if no fuctional code there
    brake
....

Best regards

--
You received this message because you are subscribed to the Google Groups "PyScripter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyscripter+...@googlegroups.com.

PyScripter

unread,
Nov 22, 2022, 5:16:00 PM11/22/22
to PyScripter
Which version of PyScripter are you using?
A few points:
- In the last couple of options there is an option under Tools, Options, IDE Options, Language Server "Check syntax as you type"
If checked whenever you type anything the source code is syntax checked.  If false, syntax checking happens just when you open or save a file.  In version 4.2.1 the default is the latter.
- Syntax checking in the last couple of versions is based on the Jedi Language Server diagnostics and may not always lead to a compilation error.
- You can get an explanation of the error by hovering the mouse on top of the error (inside the red squiggly line).

Albert Prauser

unread,
Nov 23, 2022, 12:59:50 AM11/23/22
to pyscr...@googlegroups.com
Hello,

"But, taking that ‘break’ as an example, if, at the end of the code, I go and un-indent and then re-indent the break, the squiggles disappear."

I think there is mixing ident between space and tab.

In the edit-option you can check - convert tab to space. 

Best regards
Karlsson



peet....@gmail.com

unread,
Nov 23, 2022, 2:56:05 AM11/23/22
to pyscr...@googlegroups.com

V4.2.1.0; Python 3.11

 

Just to repeat, the code runs just fine.

 

If I outdent each line then re-indent, false errors disappear.

 

 

image001.png
image002.png

peet....@gmail.com

unread,
Nov 23, 2022, 4:36:21 AM11/23/22
to pyscr...@googlegroups.com

No, that’s not the problem (and by-the-by I always use spaces anyway).

 

The code runs perfectly - complete *with* the supposed errors.  In other words, code is erroneously being flagged as having errors.

 

Peet

 

From: pyscr...@googlegroups.com <pyscr...@googlegroups.com> On Behalf Of Albert Prauser
Sent: 23 November 2022 06:00
To: pyscr...@googlegroups.com
Subject: Re: Weird false syntax errors

 

Hello,

PyScripter

unread,
Nov 23, 2022, 7:19:36 AM11/23/22
to PyScripter
Could you please submit a bug report at Issues · pyscripter/pyscripter (github.com) next time this happens, attaching the script?

In any case, I would recommend setting Tools, Options, IDE Options, Language Server "Check syntax as you type" to False.   You script would then be only checked when you open or save a file.

Indentation errors can creep in when you copy paste code say from web pages.  You can see the whitespace characters by pressing the "Show special characters" button.

Screenshot 2022-11-23 141714.png
Reply all
Reply to author
Forward
0 new messages