With or Using

Gary Walker borealis3 at home.com
Thu Apr 19 21:44:04 EDT 2001


I don't necessarily think I'm one of the five experts, but I have used
Delphi since 1.0.

The with keyword never, ever struck me one which was designed to save
keystrokes. Rather, it seemed to add clarity and succinctness to the code.
I'm a team leader of a 6 person software development effort. If members of
my team asked me my preference, I'd say use it.

Consider this:

Recipe for Lemonade

Add 8 cups water to a large pitcher
Add 1/2 cup lemon juice to a large pitcher
Add 2 cups sugar to a large pitcher
Stir the ingredients that are in the large pitcher

Now consider:

To a large pitcher add:
    8 cups water
    1/2 cup lemon juice
    2 cups sugar
    and stir.

Did the second one confuse you? Did you forget the large pitcher?? Of course
not. It's much easier to understand. So it is with with.

I believe Python allows a similar idea with the FROM keyword. If you specify
the object that you're importing from a specific module, aren't you allowed
to reference it without qualifying the module?

As in:

from SimpleHTTPServer import SimpleHTTPRequestHandler

Doesn't this allow you to now reference SimpleHTTPRequestHandler without
specifying SimpleHTTPServer?? Or am I missing something...??



>It's in Delphi all right. Now find five Delphi experts and ask them
>whether they think it's a good idea.
>
>>> It saves a small amount of typing (and not very much) at the expense of
>>> a lack of clarity and the addition of ambiguity.
>>
>>I thought with Python's block indenting it would be pretty clear what
>>was being referred to.
>>






More information about the Python-list mailing list