News for hackers. Stuff that matters.
Re:Recombine to avoid naming when naming is hard by a3n on Monday July 06, 2015 @12:37PM (#9840302)
Good idea, sometimes.

On the opposite end, I will sometimes go out of my way to name something when there isn't an immediately apparent need.

Also naming can often shorten up a long line.

Trivial example:

  In [15]: SortByLen = lambda x: len(x)
  
  In [16]: SortByLast = lambda x: x[-1]
  
  In [17]: listOfInterest = ['123', '234', '432''12', '12345', '123']
  
  In [18]: sorted(listOfInterest, key=SortByLen)
  Out[18]: ['123', '234', '123', '43212', '12345']
  
  In [19]: sorted(listOfInterest, key=SortByLast)
  Out[19]: ['43212', '123', '123', '234', '12345']

There are no comments on this comment yet.