Search code examples
pythonpylintf-string

How to handle formatting a regular string which could be a f-string [C0209]


For the following line:

print("{0: <24}".format("==> core=") + str(my_dict["core"]))

I am getting following warning message:

[consider-using-f-string] Formatting a regular string which could be a f-string [C0209]

Could I reformat it using f-string?


Solution

  • You could change the code to print(f"{'==> core=': <24}{my_dict['core']}"). The cast to string is implicit.