Web Frameworks Excessive Complexity

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Nov 21 12:43:10 CET 2012


On Wed, 21 Nov 2012 22:21:23 +1100, Chris Angelico wrote:

> Counting complexity by giving a score to every statement encourages code
> like this:
> 
> def bletch(x,y):
>   return x + {"foo":y*2,"bar":x*3+y,"quux":math.sin(y)}.get(mode,0)
> 
> instead of:
> 
> def bletch(x,y):
>   if mode=="foo": return x+y*2
>   if mode=="bar": return x*4+y
>   if mode=="quux": return x+math.sin(y) return x
> 
> Okay, this is a stupid contrived example, but tell me which of those
> you'd rather work with


Am I being paid by the hour or the line?




-- 
Steven


More information about the Python-list mailing list