[Python-Dev] PEP 203 Augmented Assignment
M.-A. Lemburg
mal@lemburg.com
Thu, 27 Jul 2000 18:09:05 +0200
Skip Montanaro wrote:
>
>
> >> Another important reason is that in cases like
> >>
> >> a[long_and_expensive_call()] = a[long_and_expensive_call()] + 1
>
> M-A> Dito for this one:
>
> M-A> i = long_and_expensive_call()
> M-A> a[i] = a[i] + 1
>
> Only if you know that long_and_expensive_call() has no side effects!
If it does, then you'll have to write the long version anyway,
if it doesn't I don't see a problem, if you don't know then
you shouldn't use the function anyway ;-))
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/