Python f-strings '=' specifier does not show colors correctly

Problem description

As shown in What’s New In Python 3.8 — Python 3.12.2 documentation, when using an ‘=’ in an f-string, it should add the variable name before the value.
This currently works, but the Replit formatting does not properly recognize this, and both the ‘=’ and the closing brace display as the ‘Strings’ color in the theme instead of the ‘Keywords’ like ‘!r’ or ‘:’ followed by an integer.

Expected behavior

The ‘=’ should use the ‘Keywords’ color and the closing brace should have the ‘Foreground’ color (as per normal)

Actual behavior

Both the ‘=’ and closing brace take on the ‘Strings’ color.

Steps to reproduce

Create a new Python program and create an f-string that uses the ‘=’ decorator.

Browser

Chrome (1), Firefox (2)

OS

Chrome OS (1), Ubuntu Linux (2)

Device if mobile

N/A

Plan

Free tier

2 Likes

The commands in the link you showed were meant to run in the shell. Here’s the code that will work outside of the shell:

from datetime import date

user = 'eric_idle'
member_since = date(1975, 7, 31)
print(f'{user=} {member_since=}')

Did you check if those are syntactically highlighted correctly? That was their only complaint here.

As of Feb 14th, 2024, the issue seems to have been fixed. Thank you to whoever did so.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.