PEP scepticism

Chris Barker chrishbarker at home.net
Tue Jul 3 17:31:10 EDT 2001


Bernhard Reiter wrote:

> Agreed.
> However not having augmented assignment made me think about it and
> the clarity you gain when writing it more explicitly.

I think one has to keep in mind that there may be greater reason to add
some of these features than just the syntactic sugar. NO coming form a
primarily C background, I saw no need for a += 2over a = a + 2, and I do
think the later is more clear an obvious. Reducin ghte need for a little
typing is NOT a good reason to add a feature (which is why that one took
so long to add). However, there are sometimes good reasons beyond the
syntactic sugar:

a += 4 means "increment a by 4"
a = a+4 means "create a new object that is the sum of a and 4, and
assign a to it"

for an integer, the result is the same, but for a mutable object, it can
do something very different:

>>> a = [1,2,3]
>>> a += [4,5,6]
>>> a
[1, 2, 3, 4, 5, 6]


The list, a can be extended without creating a new list. I'm a heavy
user of Numeric, so this can make a big difference for an array of
numbers that may be huge!

Anyway, as the original poster made it clear, he was not intending to
bring up discussion of any particular feature: my point is that a
feature that may appear to be simple syntactic sugar may turn out to
have important consequences.

-Chris

-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list