News for hackers. Stuff that matters.
Re:Anti-Patterns in Python Programming by gshubert17 on Wednesday July 09, 2014 @12:19PM (#8010453)
Since append doesn't return a value, how about:

  def append_one(var=None):
      return (var or []) + [1]
Would this take longer and/or use more storage for long lists as vars?
Re:Anti-Patterns in Python Programming by keeperofdakeys on Thursday July 10, 2014 @02:52AM (#8013958)
When you use + on two lists, a new list is created, and elements from both are copied into the new one. Whereas the append operation modifies the list, and simply adds a value. Keep in mind that a python "list" is really like a C++ vector, so while sometimes append operation sometimes allocates a new array, and copies all the values, in general is O(1). The add operation is O(n).

And besides all that, there is nothing wrong with doing an append on one line, and returning the variable on the next. It's clear and readable.

Re:Anti-Patterns in Python Programming by SEJeff on Thursday July 10, 2014 @05:54PM (#8017593)
I like this, very elegant actually.