I have many long lines like this in the project and don't know how to break it to keep PEP8 happy. PEP8 shows warning from .format(me['id'])
pic_url = "http://graph.facebook.com/{0}/picture?width=100&height=100".format(me['id'])
How can I break the line to get rid of PEP8 warning and yet don't break the code?
Long strings can be written in multiple lines by using two double quotes ( “ “ ) to break the string at any point in the middle.
Use a backslash ( \ ) as a line continuation character In Python, a backslash ( \ ) is a line continuation character. If a backslash is placed at the end of a line, it is considered that the line is continued on the next line.
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. If necessary, you can add an extra pair of parentheses around an expression, but sometimes using a backslash looks better. Make sure to indent the continued line appropriately.
You cannot split a statement into multiple lines in Python by pressing Enter . Instead, use the backslash ( \ ) to indicate that a statement is continued on the next line.
Using string literal concatenation:
pic_url = ("http://graph.facebook.com/{0}/" "picture?width=100&height=100".format(me['id']))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With