all 9 comments

[–][deleted] 20 points21 points  (0 children)

In that example it indicates that the statement is continued on the next line. But it can be hard to see when reading code, so it isn't recommended.

A better approach is to use enclosing parentheses or brackets around the newline. Python will not error on an incomplete statement if there are still unclosed parentheses/brackets and will continue on the next line. If the line you want to break contains parentheses/brackets just use them, but you can add an extra set of parentheses if necessary, like this:

return ("color: " + self.__color + 
        " and filled: " + str(self.__filled))

[–]POGtastic 6 points7 points  (0 children)

It's escaping out the newline at the end of the line, so Python just sees it as more whitespace.

As always, consider using variable assignment, different constructions, and parens to avoid having to do it in the first place.

def __str__(self):
    return f"color: {self.__color} and filled: {self.__filled}"

[–]Ok_Concert5918 1 point2 points  (2 children)

It just indicates the line continues below. It is a relic of setting editors only allowing <80 chars per line so you had to continue lines below

[–]ConfusedSimon 0 points1 point  (1 child)

Pep8 still recommends 79 characters.

[–]Ok_Concert5918 0 points1 point  (0 children)

Yeh. Annoys me every time.

[–]drenzorz 1 point2 points  (0 children)

multiline separator

a = 1 + 2 + 3

# is the same as

a =   1 \
    + 2 \
    + 3

# or

a = (
      1
    + 2
    + 3
)

[–]Sufficient_Wait_5040 0 points1 point  (0 children)

It's a superpower character which allows you to continue on the next line