How can I break up this long line in Python?

后端 未结 5 2058
忘了有多久
忘了有多久 2020-11-27 10:03

How would you go about formatting a long line such as this? I\'d like to get it to no more than 80 characters wide:

logger.info(\"Skipping {0} because its th         


        
5条回答
  •  北海茫月
    2020-11-27 10:28

    Personally I dislike hanging open blocks, so I'd format it as:

    logger.info(
        'Skipping {0} because its thumbnail was already in our system as {1}.'
        .format(line[indexes['url']], video.title)
    )
    

    In general I wouldn't bother struggle too hard to make code fit exactly within a 80-column line. It's worth keeping line length down to reasonable levels, but the hard 80 limit is a thing of the past.

提交回复
热议问题