Augmented assignment (ie. += and friends) for Python!
mwh21 at cam.ac.uk
Fri May 12 00:41:55 CEST 2000
wtanksle at dolphin.openprojects.net (William Tanksley) writes:
> On 10 May 2000 18:53:22 +0100, Michael Hudson wrote:
> >I thought I might waste some time by having a crack at implementing +=
> >and friends in Python. I think I know what I want to do on the
> >codegen side, but at the moment that hurdle looks some way off.
> Sounds like fun.
And indeed it was; I think I'm done now (well, the hard bits, anyway).
I have built myself a Python that does this:
Python 1.6a2 (#38, May 11 2000, 18:31:58) [GCC 2.95.2 19991024 (release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
>>> a *= 4
>>> a -= 4
[0, 1, 8, -1, 4, 5, 6, 7, 8, 9]
You can read about it and find a patch here:
Questions, comments, flames, praise, abuse - all welcome.
31. Simplicity does not precede complexity, but follows it.
-- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html
More information about the Python-list