How To Write Multiline Format Strings In Python

  1. place f-strings in parentheses for implied line continuation (or directly within a print statement)
  2. do not separate them by comma and do not use backslash for line continuation
  3. do signal a newline with \n except on the last line
  4. each f string line has its own f"string" notation
The preferred way of wrapping long lines is by using Python’s implied line continuation inside parentheses, brackets, and braces. 
Long lines can be broken over multiple lines by wrapping expressions in parentheses.
These should be used in preference to using a backslash for line continuation.
print(f"deleted >{branch_name}< branch\n"
f"~~~> Deletion complete")
""" OR """
multiliner = (f"deleted >{branch_name}< branch\n"
f"~~~> Deletion complete")
print(multiliner)

sources

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Raft and High Availability

Terramaster F2–422 review: This two-bay NAS box offers fast 10-gigabit ethernet streaming

LIVING THE “GIT-AH” LIFESTYLE.

FUNCTIONS — PYTHON

Journal 75 — Unity’s “The Great Fleece”, Set Up Main Menu

Information about $cBSC. Center of #Binance Smart Chain Community.

CS373 Fall 2021: Blog #7

RUN TOGETHER NFT TRIAL WHITELIST

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

More from Medium

Byte Strings Are Decoded To ASCII In IO By Default In Python

Python ternary operator

Scheduling jobs in Python

Introduction To Python Part 6