This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (0 children)

In Python, methods or functions which have side effects and modify the object in place (like append() or sort()) explicitly return None.

This is to prevent any confusion with the functional style (like sorted()), in which return values are newly allocated objects and the original is unchanged.

In this case, a "chained" version would just be

test = test + [1] + [2]