Search code examples
pythonpep8

Spliting Python string interpolation onto multiple lines


I've got a logging statement, something like:

get_logger().info(
    'Logger logging %s because we need to log it.' % response['foo']['bar']
)

With indentation it comes out well over 80 rows. If I could split it around the %, it would be fine.

How can I split this into multiple lines. (ideally without just putting response['foo']['bar'] into a variable)


Solution

  • get_logger().info(
        'Logger logging %s because we need to log it.' 
        % response['foo']['bar']
    )