total idiot question: +=, .=, etc...
bernhard at alpha1.csd.uwm.edu
Wed Jun 23 06:20:10 CEST 1999
On 22 Jun 1999 21:54:42 -0500, Preston Landers <planders at mail.utexas.edu> wrote:
>Can someone *please* give me a good reason why Python doesn't yet have
>+=, -=, and .= and other such operators? I know it's just syntactic
>sugar, but damn, it is such sweet sugar!
>From what I understand, the python creators consider it unnecessary
syntactic sugar. In fact they want one good way of writing expressions.
The lack of these operators makes the source code more readable.
+= just saves some space and typing time.
Your editor (given it is powerful enough can easily) immitate
that piece of sugar for your and make it personal syntactic honey!
Here is my posted vim example:
|>> For vim, the following does the trick (without the special word matching
|>> caps new vim versions provide. the ":noh is for people using hlsearch in
|>> vim 5.x version.)
|:map! += ^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA
|Where ":" means go into vim Commandmode
| "^[" means Esc, you have to enter it pressing Ctrl-v and then Esc
| "^M" means "Return', you have to enter pressing Ctrl-v and then Return
>Also, if this is in 1.5.2+, please forgive me, as I'm not up to speed
>on the new versions yet.
It's not in there, I guess.
Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard)
Funding/Promoting Association for a Free Informational Infrastructure (ffii.org)
More information about the Python-list