News for hackers. Stuff that matters.
Re:Special Cases Are a Code Smell by userbinator on Thursday January 24, 2019 @11:56PM (#18995678)
Indeed, in the first example the special cases should really be moved out of the loop too, so you have the code looking like this:

    - code for left edge
    - code for body
    - code for right edge
Now, both you and the machine don't have to keep thinking about the edge cases every time through the loop body. It's a win-win situation.
Re:Special Cases Are a Code Smell by elephantum on Friday January 25, 2019 @12:21AM (#18995775)
It means you have two extra special cases: 1) list is empty; 2) left edge is the right edge (I.e. length is 1)
Re:Special Cases Are a Code Smell by riskable on Friday January 25, 2019 @09:34AM (#18998161)
Nothing that can't be solved with more conditionals!

Conditionals are great because they're clear and concise...

    if not list: # Can't do anything with this
         return # or raise error
    if len(list) < 3: # Ditto
         return #ditto
Sure, there's more code but it's not bad code. It's just straightforward stuff that's easy to read and debug (if necessary).