More on "with" statement

Roman Suzi rnd at onego.ru
Sat Jul 14 08:51:20 CEST 2001


On Fri, 13 Jul 2001, Erik Max Francis wrote:

>Roman Suzi wrote:
>
>> 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
>
>That's just plain more efficient.  Four additions and one multiply

four?

>instead of three additions and four multiplies.

The same with "with": it could make name-resolving more efficient
by allowing searching some namespaces ahead of locals() and globals()...

For example (I prefer "in" instead of "with", 'cause its a
keyword already and thus no problem adding it):

import string
in string:
  a = split("1 2 3 4 45 5 6")
  l = join(a, ":")
  print l

(string is only example, I know about string methods).

The big question of course, if a and l will be in
string namespace or in locals() ;-)

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, July 14, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "A mainframe: The biggest PC peripheral available." _/





More information about the Python-list mailing list