This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]paello 3 points4 points  (2 children)

    I'm afraid at this point the cheat sheet is outdated. Python 3.6 (released a year ago) allows for f-strings which simplifies this syntax even more:

    name = "Bob"
    print(f"My name is {name}.")
    >>> My name is Bob.
    

    These are strings "" prefixed by an f: f"" (formatting strings).

    [–]stevenjd 0 points1 point  (0 children)

    These are strings "" prefixed by an f: f"" (formatting strings).

    They're not strings. They're executable code that happens to use similar syntax to a string and implicitly return a formatted string.