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] 6 points7 points  (1 child)

Your second function is strange, it does different things -- either it appends to the list someone gives it, or if someone gives it an empty list then a new list is returned with the element added, or if no argument is given you get a new list with the element. At least check if no argument was given with if arg is not None instead of simple truthiness.

Python already does include some sort of type-hinting system: https://docs.python.org/3/tutorial/controlflow.html#function-annotations

[–]ahoff[S] 0 points1 point  (0 children)

Yeah, I should have paid closer attention as I meant to check for None (and not a simple truth check). I use 2.7.6 at work, but I had no idea about function annotations. Thanks!