PATCH: Augmented assignment

Bob van der Poel bvdpoel at uniserve.com
Tue Jun 13 20:39:32 EDT 2000


Russell Wallace wrote:
> 
> > invalid.address at 127.0.0.1 (David) wrote:
> >
> > > On Fri, 9 Jun 2000 16:39:38 +0200, Thomas Wouters <thomas at xs4all.net>
> > > wrote:
> > >
> > > >As promised, here is my patch to add augmented assignment (+=, -= and
> > > >family) to Python. It's still Work In Progress, and probably requires a
> > > >rewrite of some magnitude before Guido will accept it.
> > >
> > >
> > > Why would the Python community want this?  It obfuscates code, in as much
> > > that newbies aren't likely to intuite what the symbols mean.
> 
> I disagree.  Indeed, I put it to you that
> 
>         foo += 1
> 
> is *more* intuitive than
> 
>         foo = foo + 1
> 
> It's not a huge issue, but it makes things that little bit simpler and
> more convenient; and "simpler and more convenient" is Python's raison
> d'etre, IMO.

It certainly saves more than one or two keystrokes to 'lazy typists',
expecially if using longish variable names. In addition, this syntax can
help in eliminating errors when you might:

	foobar = fooobar + 1

when, of course, you meant

	foobar =foobar + 1

I'm sure that folks who use more creative names will see more creative
examples.

I'm all for including += and -=. *= and /= would be nice, but not nearly
as useful. Auto increment/decrement is proably best left to C-guys.


-- 
   __
  /  )      /         Bob van der Poel
 /--<  ____/__        bvdpoel at uniserve.com
/___/_(_) /_)         http://users.uniserve.com/~bvdpoel



More information about the Python-list mailing list