question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing color of object in f-strings

See original GitHub issue

Problem Description

I have a very simple issue that I haven’t found an answer for here or online. Apologies if it exists somewhere. Inside of f-strings, I’m wondering if there is a way to change the color of the object. For example in, f'hello my name is {name}', I’m wondering if there is a way in spyder to set the color scheme such that {name} appears a different color than the rest of the string.

Cheers!

  • Spyder version: 4.01
  • Python version: 3.7.6
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: rhel 7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Sam-OTcommented, Sep 30, 2021

Hi @bwinsto2, we are working in improving the syntax highlighting support for Spyder 5. The improvements include better support for semantic highlighting for Python as well as supporting more languages.

Thanks, @andfoy, for your work on Spyder. I really like it and use it a lot! I just wanted to say, though, that the same issue still happens in Spyder 5.0.5. My specifications are Python 3.9.6 64-bit, Qt 5.9.7, PyQt5 5.9.2 and Windows 10 .

image

Incidentally, if I put this in the IPython console, then it behaves as desired.

image

So it seems like it has only been partially implemented?

0reactions
ccordoba12commented, Feb 17, 2022

This will be fixed in Spyder 6, to be released at the end of the year or beginning of the next one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature] Format Python f-strings with different color for code in ...
The code portion of f-strings (in { } brackets) should be formatted in a different color than the rest of the string.
Read more >
f-strings and termcolor - Python Forum
Sep-21-2019, 03:37 PM. Hi! This problem came up when I was searching for ways to colour and give styles to strings:
Read more >
Printing f-strings in color in Jupyter with escape characters in ...
My understanding is that I need Markdown to print in color, but obviously the brackets are causing problems with the f-strings in Markdown...
Read more >
How to highlight in different colors for variables inside `fstring ...
I am using python-mode which colors the parameters. When I concatinate strings the variable color is ...
Read more >
Change color of f-strings variables
Hi, I would like to know how to change the yellowish highlight of the variables inside the curly braces of f-strings. I've looked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found