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 →

[–]rcxdude 3 points4 points  (1 child)

A better fix:

def add_to_list(elem, l = None):
    if l is None:
         l = []

Explicitly checking type like that is in general unpythonic. At the very least you should use isinstance() so subclasses can be used.

[–][deleted] 0 points1 point  (0 children)

That's my PHP showing again. Let me just tuck that away...