Coding style and Python versions (was Re: Another itertool function?)

Roy Smith roy at panix.com
Mon Apr 28 18:20:41 EDT 2003


Alex Martelli <aleax at aleax.it> wrote:
> No statistically significant / measurable difference.  The tiny difference
> in conciseness is hardly compelling one way or another, either.

I disagree (respectfully).

I'm all about writing code that's easier to read.  I'll admit that the 
+= form is only marginally simplier to read, but marginal is better than 
nothing.

I tend to pick-and-choose from the XP menu, but one of the items I 
really like is "refactor mercilessly".  Why write a variable name twice 
when you can write it once?  Easier to read, and less error prone.  Have 
fun finding the typo:

cpqHeEltTolPowerSupplyRedundant = cpqHeFltTolPowerSupplyRedundant + 1

Yes, that's a real variable name from real production code.  No, we 
didn't have a choice about the name.  It's an object in a MIB and our 
coding standards require we use MIB object names literally, which was 
never a problem until we started working with this MIB :-(.




More information about the Python-list mailing list