Why does list.append evaluate to false in a boolean context? [duplicate]

Most Python methods that mutate a container in-place return None — an application of the principle of Command-query separation. (Python’s always reasonably pragmatic about things, so a few mutators do return a usable value when getting it otherwise would be expensive or a mess — the pop method is a good example of this pragmatism — but those are definitely the exception, not the rule, and there’s no reason to make append an exception).

Leave a Comment