String interpolation in Python 3.6

String interpolation is a useful feature in many programming languages which helps the developers to generate formatted messages easier. An example from C# 6 could read like:

  1. var msg = $"Value of parameter {nameof(val)} is {val}";

Scala, Ruby and some other languages have similar features. Until recently Python was not one of them. However, the recently released version 3.6 introduced, at last, string interpolation. It can be used as demonstrated:

  1. msg = f"From {start} to {finish} with some step={stepValue}"

More details can be found in PEP 498. PyCharm IDE already supports this feature in its latest version.


Add new comment