Coding style and Python versions (was Re: Another itertool function?)
Aahz
aahz at pythoncraft.com
Mon Apr 28 12:45:59 EDT 2003
In article <zAara.22169$K35.739509 at news2.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
>Aahz wrote:
>> In article <b8hc64$6n2$1 at slb9.atl.mindspring.net>,
>> Andrew Dalke <adalke at mindspring.com> wrote:
>>>
>>> i = i + 1
>>
>> I'm a little curious why you didn't write this as
>>
>> i += 1
>>
>> Any reason (i.e. still need to support 1.5.2) or just habit? If the
>> latter, why haven't you changed your habit?
>
>There is no special reason to "change that habit", e.g. not performance:
> [...]
>No statistically significant / measurable difference. The tiny difference
>in conciseness is hardly compelling one way or another, either.
However, I do think the difference in readability is somewhat compelling.
Using augmented assignment, I can think to myself, "Ah, this is mutating
an object." (This aside from the fact that numbers can't actually be
mutated -- it's a convenient mental shorthand.)
And, of course, the readability scales up rapidly with longer names.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list
mailing list