More on "with" statement
Roman Suzi
rnd at onego.ru
Fri Jul 13 14:18:45 EDT 2001
On Fri, 13 Jul 2001, Rufus V. Smith wrote:
>I went to the FAQ to check the entry about a "with" statement
>that is available in other languages. I can only think of two
>reasons to use it.
>
> 1) You're a lazy typist. (Or haven't learned to cut and paste)
>
> 2) You are generally concerned that multiple references to the
> same object with complex, multilevel access might be confusing
> to the reader or not optimized by the compiler.
Programmers must be lazy to some degree. So, they tend to write
a*(b+c+d+e)
instead of
a*b+a*c+a*d+a*e
I think, the same applies to "with".
It is also better from maintainance point of view:
you have one point to change:
(a+1)*(b+c+d+e)
while:
(a+1)*b+(a+1)*c+(a+1)*d+(a+1)*e
However, with is a border case...
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Friday, July 13, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Useless Invention: Open Toed Safety Shoes." _/
More information about the Python-list
mailing list